besmarts.core.compute module¶
besmarts.core.compute
Responsible for setting up and distributing large compute jobs
Architecture-wise, it interfaces the multiprocessing module
- besmarts.core.compute.AutoProxy(token, serializer, manager=None, authkey=None, exposed=None, incref=True, manager_owned=False)[source]¶
Return an auto-proxy for token
- besmarts.core.compute.Client(address, family=None, authkey=None, timeout=240)[source]¶
Returns a connection to the address of a Listener
- class besmarts.core.compute.Connection(handle, readable=True, writable=True)[source]¶
Bases:
ConnectionConnection class based on an arbitrary file descriptor (Unix only), or a socket handle (Windows).
- besmarts.core.compute.MakeProxyType(name, exposed, _cache={})[source]¶
Return a proxy type whose methods are given by exposed
- besmarts.core.compute.SocketClient(address, timeout=240)[source]¶
Return a connection object connected to the socket given by address
- besmarts.core.compute.dispatch(c, id, methodname, args=(), kwds={})[source]¶
Send a message to manager using connection c and return response
- class besmarts.core.compute.myiqueue(maxsize=0)[source]¶
Bases:
Queue- get(block=True, timeout=240)[source]¶
Remove and return an item from the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until an item is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Empty exception if no item was available within that time. Otherwise (‘block’ is false), return an item if one is immediately available, else raise the Empty exception (‘timeout’ is ignored in that case).
- class besmarts.core.compute.myqueue(maxsize=0)[source]¶
Bases:
Queue- get(block=True, timeout=240, n=1)[source]¶
Remove and return an item from the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until an item is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Empty exception if no item was available within that time. Otherwise (‘block’ is false), return an item if one is immediately available, else raise the Empty exception (‘timeout’ is ignored in that case).
- put(item, block=True, timeout=240, n=1)[source]¶
Put an item into the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until a free slot is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Full exception if no free slot was available within that time. Otherwise (‘block’ is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (‘timeout’ is ignored in that case).
- besmarts.core.compute.workqueue_get_workspace(wq: workqueue_remote, addr, port) workspace[source]¶
- besmarts.core.compute.workqueue_list_workspaces(wq: workqueue_remote) Dict[source]¶
- class besmarts.core.compute.workqueue_manager(address=None, authkey=None, serializer='pickle', ctx=None, *, shutdown_timeout=1.0)[source]¶
Bases:
SyncManager
- besmarts.core.compute.workqueue_new_workspace(wq: workqueue_local, address=None, shm=None, nproc=-1)[source]¶
- besmarts.core.compute.workqueue_push_workspace(wq: workqueue_local, ws: workspace)[source]¶
- besmarts.core.compute.workqueue_remove_workspace(wq: workqueue_local, ws: workspace_local)[source]¶
- besmarts.core.compute.workspace_flush(ws: workspace_local, indices, timeout: float = 240, maxwait=None, verbose=True)[source]¶
- besmarts.core.compute.workspace_is_active(ws: workspace_remote)[source]¶
- class besmarts.core.compute.workspace_local(addr, port, shm: shm_local = None, nproc=-1)[source]¶
Bases:
workspaceAssumes that we are process-local to all needed resources and do not need to use the proxy interface i.e. no connection needed
- besmarts.core.compute.workspace_local_remote_gather_thread(ws: workspace_local)[source]¶
pull results from the remote workers and put them in the local queue
- besmarts.core.compute.workspace_local_remote_loadbalance_thread(ws: workspace_local)[source]¶
pull results from the remote workers and put them in the local queue
- besmarts.core.compute.workspace_local_run(ws: workspace_local)[source]¶
Take jobs from the input queue and distribute to the processing queues, which can be a (low latency) local pool or a (high latency) manager
- besmarts.core.compute.workspace_local_run_thread(ws: workspace_local)[source]¶
- class besmarts.core.compute.workspace_manager(address=None, authkey=None, serializer='pickle', ctx=None, *, shutdown_timeout=1.0)[source]¶
Bases:
SyncManager- get_status() workspace_status[source]¶
- class besmarts.core.compute.workspace_pool(*args, **kwds)[source]¶
Bases:
Pool- Process(*args, **kwds)¶
- class besmarts.core.compute.workspace_remote(addr, port, nproc=1)[source]¶
Bases:
workspaceAssumes that we need to go through the proxy interface to access resources that are not local i.e. need to go through a connection
- besmarts.core.compute.workspace_remote_compute(wq: workqueue_remote, ws: workspace_remote)[source]¶
- besmarts.core.compute.workspace_remote_local_gather_thread(ws: workspace_remote)[source]¶
pull results from the remote workers and put them in the local queue
- besmarts.core.compute.workspace_remote_local_pusher_thread(ws: workspace_remote)[source]¶
pull results from the remote workers and put them in the local queue
- besmarts.core.compute.workspace_run(distfun: Tuple[Callable, Sequence, Mapping], workspace_address=None)[source]¶