Python concurrent.futures._base.Future() Examples
The following are 30
code examples of concurrent.futures._base.Future().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
concurrent.futures._base
, or try the search function
.
Example #1
Source File: process.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenProcessPool('A child process terminated ' 'abruptly, the process pool is not usable anymore') if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() return f
Example #2
Source File: process.py From android_universal with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenProcessPool(self._broken) if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') if _global_shutdown: raise RuntimeError('cannot schedule new futures after ' 'interpreter shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._queue_management_thread_wakeup.wakeup() self._start_queue_management_thread() return f
Example #3
Source File: thread.py From android_universal with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenThreadPool(self._broken) if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') if _shutdown: raise RuntimeError('cannot schedule new futures after ' 'interpreter shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f
Example #4
Source File: process.py From Tautulli with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #5
Source File: process.py From abu with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #6
Source File: process.py From bazarr with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #7
Source File: process.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenProcessPool('A child process terminated ' 'abruptly, the process pool is not usable anymore') if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() return f
Example #8
Source File: process.py From aws-extender with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #9
Source File: process.py From addon with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #10
Source File: process.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #11
Source File: process.py From ironpython3 with Apache License 2.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenProcessPool('A child process terminated ' 'abruptly, the process pool is not usable anymore') if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() return f
Example #12
Source File: process.py From Imogen with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenProcessPool(self._broken) if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') if _global_shutdown: raise RuntimeError('cannot schedule new futures after ' 'interpreter shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._queue_management_thread_wakeup.wakeup() self._start_queue_management_thread() return f
Example #13
Source File: thread.py From Imogen with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._broken: raise BrokenThreadPool(self._broken) if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') if _shutdown: raise RuntimeError('cannot schedule new futures after' 'interpreter shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f
Example #14
Source File: process_actor.py From ibeis with Apache License 2.0 | 6 votes |
def post(self, message): with self._shutdown_lock: if self._broken: raise process.BrokenProcessPool( 'A child process terminated ' 'abruptly, the process pool is not usable anymore') if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, message) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() return f
Example #15
Source File: process.py From faces with GNU General Public License v2.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #16
Source File: process.py From linter-pylama with MIT License | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #17
Source File: implementation.py From sslyze with GNU Affero General Public License v3.0 | 6 votes |
def result_for_completed_scan_jobs( cls, server_info: ServerConnectivityInfo, completed_scan_jobs: List[Future] ) -> RobotScanResult: if len(completed_scan_jobs) != cls._TEST_ATTEMPTS_NB: raise RuntimeError(f"Unexpected number of scan jobs received: {completed_scan_jobs}") combined_server_responses: Dict[RobotPmsPaddingPayloadEnum, List[str]] = { payload_enum: [] for payload_enum in RobotPmsPaddingPayloadEnum } for future in completed_scan_jobs: try: server_responses_per_robot_payloads = future.result() for payload_enum, server_response in server_responses_per_robot_payloads.items(): combined_server_responses[payload_enum].append(server_response) except ServerDoesNotSupportRsa: return RobotScanResult(robot_result=RobotScanResultEnum.NOT_VULNERABLE_RSA_NOT_SUPPORTED) result = RobotServerResponsesAnalyzer(combined_server_responses, cls._TEST_ATTEMPTS_NB).compute_result_enum() return RobotScanResult(result)
Example #18
Source File: process.py From plugin.video.kmediatorrent with GNU General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #19
Source File: process.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown_thread: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._pending_work_items[self._queue_count] = w self._work_ids.put(self._queue_count) self._queue_count += 1 # Wake up queue management thread self._result_queue.put(None) self._start_queue_management_thread() self._adjust_process_count() return f
Example #20
Source File: implementation.py From sslyze with GNU Affero General Public License v3.0 | 6 votes |
def result_for_completed_scan_jobs( cls, server_info: ServerConnectivityInfo, completed_scan_jobs: List[Future] ) -> SessionResumptionRateScanResult: if len(completed_scan_jobs) != cls._SESSION_ID_RESUMPTION_ATTEMPTS_NB: raise RuntimeError(f"Unexpected number of scan jobs received: {completed_scan_jobs}") successful_resumptions_count = 0 for job in completed_scan_jobs: was_resumption_successful = job.result() if was_resumption_successful: successful_resumptions_count += 1 return SessionResumptionRateScanResult( attempted_session_id_resumptions_count=cls._SESSION_ID_RESUMPTION_ATTEMPTS_NB, successful_session_id_resumptions_count=successful_resumptions_count, )
Example #21
Source File: thread.py From addon with GNU General Public License v3.0 | 5 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f
Example #22
Source File: process.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def _python_exit(): global _shutdown _shutdown = True items = list(_threads_queues.items()) if _threads_queues else () for t, q in items: q.put(None) for t, q in items: t.join(sys.maxint) # Controls how many more calls than processes will be queued in the call queue. # A smaller number will mean that processes spend more time idle waiting for # work while a larger number will make Future.cancel() succeed less frequently # (Futures in the call queue cannot be cancelled).
Example #23
Source File: process.py From addon with GNU General Public License v3.0 | 5 votes |
def _python_exit(): global _shutdown _shutdown = True items = list(_threads_queues.items()) if _threads_queues else () for t, q in items: q.put(None) for t, q in items: t.join(sys.maxint) # Controls how many more calls than processes will be queued in the call queue. # A smaller number will mean that processes spend more time idle waiting for # work while a larger number will make Future.cancel() succeed less frequently # (Futures in the call queue cannot be cancelled).
Example #24
Source File: openssl_ccs_injection_plugin.py From sslyze with GNU Affero General Public License v3.0 | 5 votes |
def result_for_completed_scan_jobs( cls, server_info: ServerConnectivityInfo, completed_scan_jobs: List[Future] ) -> OpenSslCcsInjectionScanResult: if len(completed_scan_jobs) != 1: raise RuntimeError(f"Unexpected number of scan jobs received: {completed_scan_jobs}") return OpenSslCcsInjectionScanResult(is_vulnerable_to_ccs_injection=completed_scan_jobs[0].result())
Example #25
Source File: thread.py From aws-extender with MIT License | 5 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f
Example #26
Source File: process.py From aws-extender with MIT License | 5 votes |
def _python_exit(): global _shutdown _shutdown = True items = list(_threads_queues.items()) if _threads_queues else () for t, q in items: q.put(None) for t, q in items: t.join(sys.maxint) # Controls how many more calls than processes will be queued in the call queue. # A smaller number will mean that processes spend more time idle waiting for # work while a larger number will make Future.cancel() succeed less frequently # (Futures in the call queue cannot be cancelled).
Example #27
Source File: implementation.py From sslyze with GNU Affero General Public License v3.0 | 5 votes |
def result_for_completed_scan_jobs( cls, server_info: ServerConnectivityInfo, completed_scan_jobs: List[Future] ) -> SessionResumptionSupportScanResult: total_scan_jobs_count = cls._SESSION_ID_RESUMPTION_ATTEMPTS_NB + 1 # Session ID jobs + 1 TLS ticket job if len(completed_scan_jobs) != total_scan_jobs_count: raise RuntimeError(f"Unexpected number of scan jobs received: {completed_scan_jobs}") # Sort TLS ticket VS session ID result results_dict: Dict[_ScanJobResultEnum, List[Any]] = { _ScanJobResultEnum.SESSION_ID_RESUMPTION: [], _ScanJobResultEnum.TLS_TICKET_RESUMPTION: [], } for job in completed_scan_jobs: result_enum, value = job.result() results_dict[result_enum].append(value) successful_session_id_resumptions_count = 0 for was_resumption_successful in results_dict[_ScanJobResultEnum.SESSION_ID_RESUMPTION]: if was_resumption_successful: successful_session_id_resumptions_count += 1 return SessionResumptionSupportScanResult( attempted_session_id_resumptions_count=cls._SESSION_ID_RESUMPTION_ATTEMPTS_NB, successful_session_id_resumptions_count=successful_session_id_resumptions_count, tls_ticket_resumption_result=results_dict[_ScanJobResultEnum.TLS_TICKET_RESUMPTION][0], )
Example #28
Source File: thread.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f
Example #29
Source File: process.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def _python_exit(): global _shutdown _shutdown = True items = list(_threads_queues.items()) for t, q in items: q.put(None) for t, q in items: t.join() # Controls how many more calls than processes will be queued in the call queue. # A smaller number will mean that processes spend more time idle waiting for # work while a larger number will make Future.cancel() succeed less frequently # (Futures in the call queue cannot be cancelled).
Example #30
Source File: thread.py From bazarr with GNU General Public License v3.0 | 5 votes |
def submit(self, fn, *args, **kwargs): with self._shutdown_lock: if self._shutdown: raise RuntimeError('cannot schedule new futures after shutdown') f = _base.Future() w = _WorkItem(f, fn, args, kwargs) self._work_queue.put(w) self._adjust_thread_count() return f