GearmanTaskServer
Simple multiprocessing server for gearman.
-
class gmtasks.Task(task, callback, verbose=False)[source]
This class is a simple wrapper around worker functions that does its best to
return a job to the queue if the function receives a KeyboardInterrupt or
raises an exception.
- task
- The gearman task name.
- callback
- Worker callback function.
- verbose
- If true, log.error() with exception details.
-
class gmtasks.GearmanTaskServer(host_list, tasks, max_workers=None, id_prefix=None, worker_class=None, sighandler=True, verbose=False)[source]
The main task server class.
- host_list
- List of gearman hosts to connect to. See gearman.worker for
more documentation.
- tasks
- List of tasks. Tasks may be Task() objects, dicts, lists or tuples.
- max_workers
- Number of worker processes to launch. Defaults to
cpu_count()
- id_prefix
- If you want your workers to register a client_id with gearman, provide
a prefix here. GearmanTaskServer will append an incrementing number
to the end of this, representing the total number of subprocesses
started in this run.
- worker_class
- GearmanWorker class to use. Defaults to gearman.worker.GearmanWorker.
You could also use jsonclass.GearmanWorker.
- use_sighandler
- Set to False if you would prefer to use your own signal handlers
instead of trapping SIGINT and SIGTERM as KeyboardInterrupt events.
- verbose
- Set to True to enable logger.
-
GearmanTaskServer.serve_forever()[source]
Launch the multi-process server and process jobs until an interrupt
is received.