Comments (5)
// @Rafael09ED
from p-queue.
What are you trying to achieve? 5 tasks then delay (delay starts when all the tasks are completed) or these 5 tasks must be completed in a given time?
from p-queue.
added 4 tasks
starting 2 tasks...
task 1 finished
task 2 finished
waiting 5 secs...
starting 2 tasks...
task 3 finished
task 4 finished
all done!
😄
from p-queue.
If you wanted to run at max 2 tasks every 5 seconds you can use interval = 5000
and intervalCap = 2
however I don't think that's what you are looking for. The output for the second example you gave would then be:
added 4 tasks
starting 2 tasks...
start of waiting 5 secs...
task 1 finished
task 2 finished
end of waiting 5 secs... (next two tasks may run now) (this can also happen before task 1 or 2 ends)
starting 2 tasks...
task 3 finished
task 4 finished
all done!
For the exact behavior you have described where it waits five seconds after all have finished, I would look into using the .onIdle()
promise or Promise.all()
with a timeout for 5 seconds that then adds the next set of promises you want to run.
from p-queue.
Ok. I know Promise.all()
is a possibility. Just wanted to make sure if it could be done with the queue itself.
Thanks anyways!
from p-queue.
Related Issues (20)
- Timeout option question
- '/node_modules/eventemitter3/index.js' does not provide an export named 'default' HOT 2
- Again '/node_modules/eventemitter3/index.js' does not provide an export named 'default' HOT 1
- TypeError: PQueue is not a constructor HOT 1
- [Feature request] Get number of tasks before one
- Jest detects open handles on queue.add()
- Default value for priority doesn't get applied
- How do I only add items up until the concurrency limit and then wait until a pending promise is fulfilled?
- `PQueue.on` does not exist HOT 7
- How can I use jest fake timers when testing code that use p-queue?
- EventEmitter import breaks TypeScript
- [7.4.0] Type regression when node16 module/moduleResolution
- Weakmap.get is not a function HOT 7
- [react-native] privateMap.get is not a function HOT 3
- p-queue is not correctly exported and breaks Bundlephobia and unpkg. HOT 2
- AsyncLocalStorage execution context not propagated correctly
- TypeScript TS2344 error with enabled "exactOptionalPropertyTypes" setting.
- internal `pending` count out of sync
- Documentation: I feel I have a use-case that I'm not sure if the queue fulfils when reading the doc
- Feature Request - awaitNextInterval HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p-queue.