distributed 2021.10.0

This includes a global :None:None:`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.

This code copies and modifies two functions from the concurrent.futures.thread module, notably :None:None:`_worker` and ThreadPoolExecutor._adjust_thread_count` to allow for checking against a global threading.local state. These functions are subject to the following license, which is included as a comment at the end of this file:

https://docs.python.org/3/license.html

... and are under copyright by the Python Software Foundation

Copyright 2001-2016 Python Software Foundation; All Rights Reserved

Modified ThreadPoolExecutor to support threads leaving the thread pool

Modified ThreadPoolExecutor to support threads leaving the thread pool

This includes a global :None:None:`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.

This code copies and modifies two functions from the concurrent.futures.thread module, notably :None:None:`_worker` and ThreadPoolExecutor._adjust_thread_count` to allow for checking against a global threading.local state. These functions are subject to the following license, which is included as a comment at the end of this file:

https://docs.python.org/3/license.html

... and are under copyright by the Python Software Foundation

Copyright 2001-2016 Python Software Foundation; All Rights Reserved

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /distributed/threadpoolexecutor.py#0
type: <class 'module'>
Commit: