compass.services.cpu.ProcessPoolService#
- class ProcessPoolService(**kwargs)[source]#
Bases:
Service
Service that contains a ProcessPoolExecutor instance
- Parameters:
**kwargs – Keyword-value argument pairs to pass to
concurrent.futures.ProcessPoolExecutor
. By default,None
.
Methods
Open thread pool and temp directory
call
(*args, **kwargs)Call the service
process
(*args, **kwargs)Process a call to the service.
process_using_futures
(fut, *args, **kwargs)Process a call to the service
Shutdown thread pool and cleanup temp directory
Attributes
Max number of concurrent job submissions.
Check if process function can be called.
Service name used to pull the correct queue object
- MAX_CONCURRENT_JOBS = 10000#
Max number of concurrent job submissions.
- async classmethod call(*args, **kwargs)#
Call the service
- Parameters:
*args, **kwargs – Positional and keyword arguments to be passed to the underlying service processing function.
- Returns:
obj
– A response object from the underlying service.
- abstract property can_process#
Check if process function can be called.
This should be a fast-running method that returns a boolean indicating whether or not the service can accept more processing calls.
- abstractmethod async process(*args, **kwargs)#
Process a call to the service.
- Parameters:
*args, **kwargs – Positional and keyword arguments to be passed to the underlying processing function.
- async process_using_futures(fut, *args, **kwargs)#
Process a call to the service
- Parameters:
fut (
asyncio.Future
) – A future object that should get the result of the processing operation. If the processing function returnsanswer
, this method should callfut.set_result(answer)
.**kwargs – Keyword arguments to be passed to the underlying processing function.