bittensor.core.threadpool#

Implements ThreadPoolExecutor.

Attributes#

Exceptions#

Classes#

PriorityThreadPoolExecutor

Base threadpool executor with a priority queue.

Module Contents#

exception bittensor.core.threadpool.BrokenThreadPool#

Bases: concurrent.futures._base.BrokenExecutor

Raised when a worker thread in a ThreadPoolExecutor failed initializing.

Initialize self. See help(type(self)) for accurate signature.

bittensor.core.threadpool.NULL_ENTRY#
class bittensor.core.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.

Initializes a new ThreadPoolExecutor instance.

Parameters:
  • max_workers – The maximum number of threads that can be used to execute the given calls.

  • thread_name_prefix – An optional name prefix to give our threads.

  • initializer – An callable used to initialize worker threads.

  • initargs – A tuple of arguments to pass to the initializer.

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.core.config.Config

property is_empty#
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

bittensor.core.threadpool.logger#