bittensor.threadpool#

Implements ThreadPoolExecutor.

Module Contents#

Classes#

_WorkItem

PriorityThreadPoolExecutor

Base threadpool executor with a priority queue

Functions#

_worker(executor_reference, work_queue, initializer, ...)

Attributes#

__author__

_threads_queues

_shutdown

NULL_ENTRY

bittensor.threadpool.__author__ = 'Brian Quinlan (brian@sweetapp.com)'#
bittensor.threadpool._threads_queues#
bittensor.threadpool._shutdown = False#
class bittensor.threadpool._WorkItem(future, fn, start_time, args, kwargs)#

Bases: object

run()#

Run the given work item

bittensor.threadpool.NULL_ENTRY = ()#
bittensor.threadpool._worker(executor_reference, work_queue, initializer, initargs)#
exception bittensor.threadpool.BrokenThreadPool#

Bases: concurrent.futures._base.BrokenExecutor

Raised when a worker thread in a ThreadPoolExecutor failed initializing.

class bittensor.threadpool.PriorityThreadPoolExecutor(maxsize=-1, max_workers=None, thread_name_prefix='', initializer=None, initargs=())#

Bases: concurrent.futures._base.Executor

Base threadpool executor with a priority queue

property is_empty#
_counter#
classmethod add_args(parser, prefix=None)#

Accept specific arguments from parser

Parameters:
classmethod config()#

Get config from the argument parser Return: bittensor.config object

Return type:

bittensor.config

submit(fn, *args, **kwargs)#

Submits a callable to be executed with the given arguments.

Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.

Returns:

A Future representing the given call.

Parameters:

fn (Callable) –

Return type:

concurrent.futures._base.Future

_adjust_thread_count()#
_initializer_failed()#
shutdown(wait=True)#

Clean-up the resources associated with the Executor.

It is safe to call this method several times. Otherwise, no other methods can be called after this one.

Parameters:
  • wait – If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed.

  • cancel_futures – If True then shutdown will cancel all pending futures. Futures that are completed or running will not be cancelled.