Add support for task priority to the standard :class:`concurrent.futures.ThreadPoolExecutor` FIFO-queue based :class:`concurrent.futures.Executor` implementation. Interface is identical to :class:`concurrent.futures.ThreadPoolExecutor`, except the `.submit()` which now accepts optio
| 98 | |
| 99 | |
| 100 | class PriorityThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor): |
| 101 | """Add support for task priority to the standard |
| 102 | :class:`concurrent.futures.ThreadPoolExecutor` FIFO-queue based |
| 103 | :class:`concurrent.futures.Executor` implementation. |
| 104 | |
| 105 | Interface is identical to :class:`concurrent.futures.ThreadPoolExecutor`, |
| 106 | except the `.submit()` which now accepts optional `priority` keyword |
| 107 | argument:: |
| 108 | |
| 109 | def submit(self, fn, *args, priority=sys.maxsize, **kwargs): |
| 110 | ... |
| 111 | |
| 112 | Note: if `priority` is omitted, the behavior is identical to that of the |
| 113 | superclass, `ThreadPoolExecutor`. |
| 114 | """ |
| 115 | |
| 116 | def __init__(self, *args, **kwargs): |
| 117 | super().__init__(*args, **kwargs) |
| 118 | self._work_queue = _PrioritizingQueue() |
| 119 | |
| 120 | |
| 121 | class Present(concurrent.futures.Future): |
no outgoing calls