Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/abort listener execution #484

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b274b8e
feat: add std stream event emit for abort handlers
joshLong145 Nov 30, 2024
ba38228
ref: remove log
joshLong145 Nov 30, 2024
f9b4919
feat: add event emit from abort handler
joshLong145 Dec 2, 2024
1f235f3
ref: lower test timeouts
joshLong145 Dec 2, 2024
9ac04b4
ref: change option assignment to tracked task
joshLong145 Dec 3, 2024
650128d
fmt
joshLong145 Dec 4, 2024
85de985
ref: change abort listener execution to fuffil on first promise to re…
joshLong145 Dec 7, 2024
18e4853
feat: add tracking tasks to busy check
joshLong145 Dec 8, 2024
0685ae3
feat: add event handlers for abort start and resolution
joshLong145 Dec 11, 2024
4a892d2
test: abort test refactor (wip)
joshLong145 Dec 11, 2024
e824a79
ref: add default for tracking task options
joshLong145 Dec 11, 2024
efb12c6
ref: rename event handler
joshLong145 Dec 11, 2024
8987fa3
ref: refactor std handler
joshLong145 Dec 12, 2024
f5c38fd
ref: move tracking task deletion after task check
joshLong145 Dec 12, 2024
622ed7d
Merge branch 'feat/std-streams-task-abort' of github.com:joshLong145/…
joshLong145 Dec 12, 2024
9d85663
ref: move abort resolver handler call to worker termination if rejecting
joshLong145 Dec 13, 2024
7c1e099
dev: refactor abort example to show implemented changes
joshLong145 Dec 13, 2024
29c2a51
Merge branch 'master' of github.com:josdejong/workerpool into fix/abo…
joshLong145 Jan 1, 2025
ad9534d
ref: add default for abort resolution handler
joshLong145 Jan 1, 2025
7d24650
move to terminationHandler over pool controlled worker cleanup
joshLong145 Feb 6, 2025
0e0448a
clarify example
joshLong145 Feb 6, 2025
e183786
refactor event listeners for abort op lifecycle
joshLong145 Feb 9, 2025
7e9fa7e
cleanup tests
joshLong145 Feb 9, 2025
90c86ac
update example
joshLong145 Feb 12, 2025
518e7ad
cleanup WorkerHandler
joshLong145 Feb 16, 2025
700be64
rename taskResolver abortResolver change type to promise
joshLong145 Feb 17, 2025
d331a58
remove event argument types for test compilation
joshLong145 Feb 17, 2025
a1c7ccf
update new event handler argument types
joshLong145 Feb 17, 2025
e44d73a
ref: delete tracking task on abort timeout
joshLong145 Feb 23, 2025
0b1b9f9
feat: add abortResolver passthrough to WorkerHandler from pool exec o…
joshLong145 Feb 23, 2025
9e9f7a9
test: abortResolver tests
joshLong145 Feb 23, 2025
1023cc8
ref: rename AbortStartArgs.abortResolver to abortPromise
joshLong145 Feb 23, 2025
1a50ba3
fix: use ternary
joshLong145 Mar 6, 2025
76cd6c6
test: fix formatting
joshLong145 Mar 6, 2025
2a122e1
Revert "test: fix formatting"
joshLong145 Mar 6, 2025
361bccd
test: revert formatting
joshLong145 Mar 6, 2025
590de65
test: revert to upstream master
joshLong145 Mar 6, 2025
67f60dc
test: add test updates for abort handlers suite
joshLong145 Mar 6, 2025
985f5db
ref: cleanup example
joshLong145 Mar 6, 2025
0a86658
ref: timeout handler triggers in parent before message can be sent fr…
joshLong145 Mar 8, 2025
b8484f7
fix: remove log
joshLong145 Mar 8, 2025
34a8db7
ref: cleamup examples
joshLong145 Mar 8, 2025
0a9ccaf
fix: add back abort resolver for non error case
joshLong145 Mar 9, 2025
d3e707f
ref: use turnaries
joshLong145 Mar 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ref: cleamup examples
joshLong145 committed Mar 8, 2025
commit 34a8db7a31d17dd06d9977732a34bb489325fcfb
11 changes: 6 additions & 5 deletions examples/abort.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ const pool = workerpool.pool(__dirname + "/workers/cleanupAbort.js", {
maxWorkers: 1,
});

const main = async () => {
const main = async function() {
let abortResolverSuccess;
await pool
.exec("asyncTimeout", [], {
@@ -34,8 +34,8 @@ const main = async () => {
console.log("timeout handled: ", err.message);
});

await abortResolverSuccess.catch((err) => {
console.log("abort operation concluded ", err);
await abortResolverSuccess.then((err) => {
console.log("abort operation resolved for asyncTimeout");
});

console.log("pool status after abort operation:", pool.stats());
@@ -61,8 +61,9 @@ const main = async () => {
console.log("cancel occured: ", err.message);
});

await abortResolverFailure.catch((e) => {
console.log("cancelation handled: ", e.message);

await abortResolverFailure.then(() => {
console.log("cancelation handled for asyncAbortHandlerNeverResolves");
});

console.log("final pool stats", pool.stats());
8 changes: 4 additions & 4 deletions examples/workers/cleanupAbort.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ function asyncTimeout() {
return new Promise(function (resolve) {
let timeout = setTimeout(() => {
resolve();
}, 5000);
}, 5000);

// An abort listener allows for cleanup for a given worker
// such that it may be resused for future tasks
@@ -23,7 +23,7 @@ function asyncAbortHandlerNeverResolves() {
return new Promise((resolve) => {
let timeout = setTimeout(() => {
resolve();
}, 5000);
}, 1_000_000_000);

// An abort listener allows for cleanup for a given worker
// such that it may be resused for future tasks
@@ -36,7 +36,7 @@ function asyncAbortHandlerNeverResolves() {
res();
resolve();
// set the timeout high so it will not resolve before the external
// timeout triggers and exits the worker
// timeout triggers and exits the worker
}, 1_000_000_000);
});
});
@@ -52,4 +52,4 @@ workerpool.worker(
{
abortListenerTimeout: 1000
}
);
);