gmtasks contains a simple multiprocessing server for Gearman workers, designed for ease of configuration and maximum availability. It includes a task wrapper class that traps any interrupts or exceptions that might be thrown by your task methods, and attempts to make sure that the affected job is re-inserted into the queue (which is not the default behavior if the worker script exits abnormally)
Please see the full documentation for more detailed information.
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.',
worker_class = GearmanWorker,
use_sighandler = True, # SIGINT and SIGTERM send KeyboardInterrupt
verbose = True, # log.info() and log.error() messages
)
# Run the loop
server.serve_forever()
Download
Metadata
Release files for gmtasks 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gmtasks-0.4.tar.gz | 6.2 kB | Without provenance | Details for gmtasks-0.4.tar.gz |
Release files / gmtasks-0.4.tar.gz
| Download URL | gmtasks-0.4.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c5d389ff9bed4ae54d3435cfc1c64803862f936629418b1f0239a3cf417074d
|
|
BLAKE2b-256 checksum How to use checksums |
57692c66bd32adcf444730f5cf67863bdd1c6e7988e36e07757f861e00afa2b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for gmtasks 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.