spawners package¶
Submodules¶
spawners.base module¶
-
class
micro_framework.spawners.base.CallItem(task_id, target, *target_args, **target_kwargs)¶ Bases:
object-
classmethod
from_task(task)¶
-
classmethod
-
class
micro_framework.spawners.base.Spawner¶ Bases:
objectMixin to Executors
-
kill()¶
-
spawn(target_fn, *fn_args, callback=None, **fn_kwargs)¶
-
stop(wait=True)¶
-
-
class
micro_framework.spawners.base.Task(task_id, target, *target_args, **target_kwargs)¶ Bases:
object-
run()¶
-
-
micro_framework.spawners.base.worker_init()¶
spawners.multiprocess module¶
-
class
micro_framework.spawners.multiprocess.ProcessPoolSpawner(max_workers=None, mp_context=None, initializer=None, initargs=(), **kwargs)¶ Bases:
micro_framework.spawners.base.Spawner,concurrent.futures.process.ProcessPoolExecutor-
shutdown(wait: bool = Ellipsis) → None¶ 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.
- Args:
- 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.
-
-
class
micro_framework.spawners.multiprocess.ProcessSpawner(max_workers=3, max_tasks_per_child=None, **kwargs)¶ Bases:
micro_framework.spawners.base.Spawner,concurrent.futures._base.Executor-
create_task(target, *target_args, **target_kwargs)¶
-
initiate_pool()¶
-
initiate_queue_task()¶
-
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.
- Args:
- 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.
-
start_new_process()¶
-
submit(target_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.
-
terminate_process(process)¶
-
-
micro_framework.spawners.multiprocess.process_initializer()¶
-
micro_framework.spawners.multiprocess.process_worker(call_queue, result_queue, max_tasks)¶
spawners.thread module¶
-
class
micro_framework.spawners.thread.ThreadPoolSpawner(max_workers=None, thread_name_prefix='', initializer=None, initargs=(), **kwargs)¶ Bases:
micro_framework.spawners.base.Spawner,concurrent.futures.thread.ThreadPoolExecutor-
shutdown(wait: bool = Ellipsis) → None¶ 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.
- Args:
- 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.
-
-
class
micro_framework.spawners.thread.ThreadSpawner(max_workers=3, **kwargs)¶ Bases:
micro_framework.spawners.base.Spawner,concurrent.futures._base.Executor-
create_task(target, *target_args, **target_kwargs)¶
-
initiate_pool()¶
-
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.
- Args:
- 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.
-
start_new_thread()¶
-
stop_thread(thread)¶
-
-
micro_framework.spawners.thread.thread_worker(executor, write_queue, stop_event: threading.Event)¶