-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support aborting the mapping #28
Comments
Perhaps expose or pass a Symbol? |
Where would you change the concurrency? Inside the map function? |
Can you show an example of how that would be used? |
Here's an example: https://github.com/breejs/bree#nodejs-email-queue-job-scheduling-example Regarding the Symbol, I'm not sure to be honest because there would need to be support for multiple instances somehow. |
In the prior link shared, I am referencing this snippet: // handle cancellation (this is a very simple example)
if (parentPort)
parentPort.once('message', message => {
//
// TODO: once we can manipulate concurrency option to p-map
// we could make it `Number.MAX_VALUE` here to speed cancellation up
// <https://github.com/sindresorhus/p-map/issues/28>
//
if (message === 'cancel') isCancelled = true;
}); |
While I agree that the ability to dynamically change the concurrency could be useful, in the example you reference, I think what you actually want is the ability to abort the |
Yes that would be great! |
Both would, but the latter you mention would solve the immediate issue. |
@sindresorhus Interesting idea of using the mapper reference itself to abort, but wouldn't it be better to add an - await pMap(foo, bar);
+ const mapping = pMap(foo, bar);
+ setTimeout(mapping.abort, 5000);
+ await mapping; |
Yeah, good point. Maybe supporting AbortController would be an even better solution. |
Duplicate of #31 |
e.g. a few seconds into waiting for the promise to finish, we could increase concurrency due to CPU limit being lowered below 20%, to a concurrency of 5x or something. Basically dynamic concurrency
The text was updated successfully, but these errors were encountered: