elm.ords.services.base.Service

class Service[source]

Bases: ABC

Abstract base class for a Service that can be queued to run.

Methods

acquire_resources()

Use this method to allocate resources, if needed

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.

release_resources()

Use this method to clean up resources, if needed

Attributes

MAX_CONCURRENT_JOBS

Max number of concurrent job submissions.

can_process

Check if process function can be called.

name

Service name used to pull the correct queue object.

MAX_CONCURRENT_JOBS = 10000

Max number of concurrent job submissions.

async classmethod call(*args, **kwargs)[source]

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.

property name

Service name used to pull the correct queue object.

Type:

str

async process_using_futures(fut, *args, **kwargs)[source]

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 returns answer, this method should call fut.set_result(answer).

  • **kwargs – Keyword arguments to be passed to the underlying processing function.

acquire_resources()[source]

Use this method to allocate resources, if needed

release_resources()[source]

Use this method to clean up resources, if needed

abstract property can_process

Check if process function can be called.

This should be a fast-running method that returns a boolean indicating wether or not the service can accept more processing calls.

abstract async process(*args, **kwargs)[source]

Process a call to the service.

Parameters:

*args, **kwargs – Positional and keyword arguments to be passed to the underlying processing function.