plynx.service.worker

Module Contents

class plynx.service.worker.TickThread(executor)[source]

Bases: object

This class is a Context Manager wrapper. It calls method tick() of the executor with a given interval

TICK_TIMEOUT = 1[source]
__enter__(self)[source]

Currently no meaning of returned class

__exit__(self, type, value, traceback)[source]
call_executor_tick(self)[source]
class plynx.service.worker.Worker(worker_config, worker_id)[source]

Bases: object

Worker main class.

Args:
server_address (tuple): Define the server address (host, port). RequestHandlerClass (TCP handler): Class of socketserver.BaseRequestHandler.

Currently implemented as a TCP server.

Only a single instance of the Worker class in a cluster is allowed.

On the high level Worker distributes Jobs over all available Workers and updates statuses of the Graphs in the database.

Worker performs several roles:
  • Pull graphs in status READY from the database.
  • Create Schedulers for each Graph.
  • Populate the queue of the Jobs.
  • Distribute Jobs accross Workers.
  • Keep track of Job’s statuses.
  • Process CANCEL requests.
  • Update Graph’s statuses.
  • Track worker status and last response.
SDB_STATUS_UPDATE_TIMEOUT = 1[source]
WORKER_STATE_UPDATE_TIMEOUT = 1[source]
serve_forever(self)[source]

Run the worker.

execute_job(self, executor)[source]
_run_db_status_update(self)[source]

Syncing with the database.

_run_worker_state_update(self)[source]

Syncing with the database.

stop(self)[source]

Stop worker.

plynx.service.worker.run_worker(worker_id=None)[source]

Run worker daemon. It will run in the same thread.