Gearman Task Server
Project description
Simple multiprocessing server for gearman.
Until I get a chance to write better documentation, please look at the sample usage below.
Sample usage
from multiprocessing import freeze_support
from gmtasks.jsonclass import GearmanWorker
from gmtasks import GearmanTaskServer, Task
# Jobs
def job1(worker, job):
return job.data['string1']
def job2(worker, job):
return job.data['string2']
def job3(worker, job):
return job.data['string3']
# Main loop
if __name__ == '__main__':
# Need this to run in Windows
freeze_support()
# Import all of the jobs we handle
tasks = [
Task('job1', job1),
{'task': 'job2', 'callback': job2},
['job3', job3],
]
# Initialize the server
server = GearmanTaskServer(
host_list = ['localhost:4730'],
tasks = tasks,
max_workers = None, # Defaults to multiprocessing.cpu_count()
id_prefix = 'myworker.',
GMWorker = GearmanWorker,
sighandler = True, # SIGINT and SIGTERM send KeyboardInterrupt
verbose = True, # log.info() and log.error() messages
)
# Run the loop
server.serve_forever()
Download
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gmtasks-0.2.tar.gz
(5.3 kB
view details)
File details
Details for the file gmtasks-0.2.tar.gz.
File metadata
- Download URL: gmtasks-0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61f456f8aa7b00b70b0b4b97be3fe16c30f928413019751f2bb49325e38aac18
|
|
| MD5 |
d17d2f1041df4301e85da9e8ec98626f
|
|
| BLAKE2b-256 |
655af86f539f176ee18b0c83307a233d64d836e3da965e3b83f37d39719fe920
|