Launch tasks from other tasks#471
Conversation
|
Supercedes #432 |
7ef09bf to
2a9f855
Compare
|
There are two ways in which this can deadlock.
The first case is unfortunate, but somewhat controllable and unlikely. The second case can happen more easily and is harder to control for. Because we're not using coroutines/generator functions we don't have an easy way to jump out of the task and free up the thread. I think our only option here is to add another thread to the ThreadPoolExecutor. This can be done dynamically by changing private variables however the standard |
|
I've resolved the more serious of the deadlocks by allowing tasks that call |
7910412 to
b8fb0cf
Compare
|
OK, now scatter dumps data directly to the local worker's data dict, bypassing the scheduler. Additionally I've removed the first deadlock by temporarily increasing the number of slots on any worker that is running a client. |
747e536 to
8662ee8
Compare
|
I'm now pretty happy with this. Merging on passed tests |
Modified ThreadPoolExecutor to support threads leaving the thread pool This includes a global `secede` method that a submitted function can call to have its thread leave the ThreadPoolExecutor's thread pool. This allows the thread pool to allocate another thread if necessary and so is useful when a function realises that it is going to be a long-running job that doesn't want to take up space. When the function finishes its thread will terminate gracefully. use threadpoolexecutor in worker Add new WorkerExecutor class This is the client that a Worker gets internally. Currently it is exactly the same, except that `_scatter` dumps to the local worker's data. Remove deadlock from long-running tasks Previously when tasks that created clients ran, they might a slot on the scheduler for a long time, potentially causing deadlocks. Now we increase the number of slots for that worker whenever a task spins up a client, removing the deadlock but opening ourselves up to over-saturation. update docs add WorkerExecutor._gather method add docstrings add PSF license
8662ee8 to
6de0bbc
Compare
This allows the spawning of tasks from other tasks. We don't add any new scheduling functionality. Instead we make it more convenient to start a client from a task.
See associated doc page for more information.