feature request: get active tasks details
I would like to see what are active tasks.
Is it possible to save main and params in workers->processing. And eventually get them in pool.stats()
Thanks for the suggestion. That could be interesting, I think this will be quite easy and will not introduce any overhead.
I don't think you always have stats() return this list methods/args of all queued and active tasks, since that can cost performance. We could extend the stats method with an option, something like:
Pool.stats({taskContents: true})
and then the response could be:
{
totalWorkers: 0,
busyWorkers: 0,
idleWorkers: 0,
pendingTasks: 0,
activeTasks: 0,
pendingTaskContents: [
{method: ..., args: [...]},
...
]
activeTaskContents: [
{method: ..., args: [...]},
...
]
}
would that make sense?
yes that's seems a good solution.
Thank you josdejong for the great library.
To add on to this request - it'll be really helpful if we can get details of the current tasks either running or queued, so we can avoid creating redundant tasks. Any way to do this already?
What you could do right now is creating some sort of a wrapper around your tasks and keep these statistics yourself:
const myRunningTasks = { }
function myTask() {
myRunningTasks[myTaskId] = true
doTheRealWork()
delete myRunningTasks[myTaskId]
}