FEV_KEGG.lib.Python.concurrent.futures module

class FEV_KEGG.lib.Python.concurrent.futures.InterruptibleProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=())[source]

Bases: concurrent.futures.process.ProcessPoolExecutor

This class inherits from concurrent.futures.ProcessPoolExecutor and only replaces the worker function which pulls work items from the call_queue and reports their results back on the result_queue. A KeyboardInterrupt can be caught during execution of the work item, but not when the next work item is being pulled from the call_queue! A KeyboardInterrupt stack trace is printed and the process dies. This class catches a KeyboardInterrupt during call_queue-pulling and causes the current process (one within the pool) to sys.exit() immediately, without printing a KeyboardInterrupt stack trace. Per default, sys.exit() does not cause a stack trace print.

Initializes a new ProcessPoolExecutor instance.

Parameters:
  • max_workers – The maximum number of processes that can be used to execute the given calls. If None or not given then as many worker processes will be created as the machine has processors.
  • mp_context – A multiprocessing context to launch the workers. This object should provide SimpleQueue, Queue and Process.
  • initializer – A callable used to initialize worker processes.
  • initargs – A tuple of arguments to pass to the initializer.
FEV_KEGG.lib.Python.concurrent.futures.process_worker(call_queue, result_queue)[source]

A copy of Python’s process_worker function in concurrent.futures.ProcessPoolExecutor.

This copy was changed to not die on KeyboardInterrupt, but to exit gracefully. Also, no traceback is printed upon NoKnownPathwaysError or CancelledError.

Note

Copyright © 2001-2018 Python Software Foundation; All Rights Reserved