MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / PriorityThreadPoolExecutor

Class PriorityThreadPoolExecutor

dwave/cloud/concurrency.py:100–118  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

98
99
100class 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
121class Present(concurrent.futures.Future):

Callers 3

__init__Method · 0.90
test_fallbackMethod · 0.90
test_prioritizationMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_fallbackMethod · 0.72
test_prioritizationMethod · 0.72