question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support question - read remaining number of tasks in async.queue

See original GitHub issue

I am using async.queue like so:

const q = async.queue((task, cb => task(cb));

How can I find out during debugging how many tasks remain on the queue (and maybe how many have completed?)?

I used util.inspect() to get the properties on the queue

 { _tasks: DLL { tail: null, head: null, length: 0 },
  concurrency: 3,
  payload: 1,
  saturated: [Function: noop],
  unsaturated: [Function: noop],
  buffer: 0.75,
  empty: [Function: noop],
  drain: [Function],
  error: [Function: noop],
  started: false,
  paused: false,
  push: [Function: push],
  kill: [Function: kill],
  unshift: [Function: unshift],
  remove: [Function: remove],
  process: [Function: process],
  length: [Function: length],
  running: [Function: running],
  workersList: [Function: workersList],
  idle: [Function: idle],
  pause: [Function: pause],
  resume: [Function: resume] }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
aearlycommented, Oct 1, 2017

q.length() will return the length of the queue. q._tasks.toArray() will give you a list of tasks in the queue. There’s no way to tell how many have completed, unless you track that yourself.

To remove the drain callback:

q.drain = function () {}

No way to use multiple drain callbacks, but you can call multiple functions in the single drain callback.

0reactions
ORESoftwarecommented, Jul 28, 2019

Still don’t know what the diff is between q.length() and q.running()

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS async / await tasks queue - javascript
Random enqueue() leads to a big number of "waiting" tasks. Makes sense, since we enqueued all tasks within first ~4000ms , they must...
Read more >
How Does the Asynchronous Task Processing System ...
A large number of tasks can be completed faster at a reasonable cost by scaling the resources of the asynchronous task processing system....
Read more >
Implementing an Asynchronous Dispatch Queue
Our goal is to make our dispatch queue generic enough that we can change the number of threads for each queue we create....
Read more >
Async/Await - Best Practices in Asynchronous Programming
The method is able to complete, which completes its returned task, and there's no deadlock.
Read more >
DispatchQueue | Apple Developer Documentation
If too many tasks block, the system may run out of threads for your app. ... concurrent dispatch queues exacerbates the thread consumption...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found