How add async functions to queue?
See original GitHub issueI am trying to add an async function to the queue. While the function is executed, the task appears to stay in the queue. e.g. the queue length remains at 1.
Here is some example code:
const Queue = require('queue');
const queue = new Queue({ autostart: true });
async function output() {
console.log('hi');
}
queue.push(async (cb) => {
await output();
cb();
});
What am I missing?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
JS async / await tasks queue - javascript - Stack Overflow
A queue helps us to straighten tasks in an async environment into a sync pattern. That is exactly what we want. ➜ "Run...
Read more >Node.js async.queue() Method - GeeksforGeeks
The async module is is designed for working with asynchronous JavaScript in NodeJS. The async.queue returns a queue object which is capable ...
Read more >async.queue() Method in Node.js - Tutorialspoint
The async module provides different functionalities to work with asynchronous JavaScript in a nodejs application. The async.queue() method ...
Read more >Implementing an async queue in 23 lines of code
A task will be a function that if called returns a promise. · The queue accepts an array of tasks and the maximum...
Read more >async-await-queue - npm
Start using async-await-queue in your project by running `npm i ... There are 15 other projects in the npm registry using async-await-queue.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ah makes sense, your example didn’t show any concurrency limit so i assumed you wanted parallel execution (which is what Promise.all is good at)
My use case is that I have a task that must only have one instance running at a time. I am using a queue with concurrency = 1 to ensure that.