bittensor.threadpool#

Implements ThreadPoolExecutor.

Module Contents#

Classes#

PriorityThreadPoolExecutor

Base threadpool executor with a priority queue

_WorkItem

Functions#

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

Attributes#

NULL_ENTRY

__author__

_shutdown

_threads_queues

exception bittensor.threadpool.BrokenThreadPool#

Bases: concurrent.futures._base.BrokenExecutor

Raised when a worker thread in a ThreadPoolExecutor failed initializing.

bittensor.threadpool.NULL_ENTRY = ()#
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#
_adjust_thread_count()#
_initializer_failed()#
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

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.

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

class bittensor.threadpool._WorkItem(future, fn, start_time, args, kwargs)#

Bases: object

run()#

Run the given work item

bittensor.threadpool.__author__ = 'Brian Quinlan (brian@sweetapp.com)'#
bittensor.threadpool._shutdown = False#
bittensor.threadpool._threads_queues#
bittensor.threadpool._worker(executor_reference, work_queue, initializer, initargs)#