Skip to main content

A tool for creating external worker processes

Project description

Worker Process

This package provides a wrapper to create standalone worker processes.

Example Worker

Workers are created by extending the BaseWorker class and implementing a tick method to execute then calling .main() on the class. This will start an infinite loop calling that function.

The worker can be rate limited with max_ticks_per_second.

The worker can be stopped gracefully by sending a SIGTERM to the process.

>>> import time
...
... from workerprocess import BaseWorker
...
...
... class ExampleWorker(BaseWorker):
...
...     max_ticks_per_second = 10
...
...     def tick(self):
...         print 'Tick!'
...         time.sleep(1)
...
... ExampleWorker.main()

A sighup method on the function will be called if the process receives a SIGHUP

Running the Worker

The easiest way to be able to run the worker is by adding a console_script entry point in your setup.py:

entry_points=””” [console_scripts] example_worker_process = yourpackage.yourmodule:ExampleWorker.main “””,

After installing your package you will be able to run the command example_worker_process from the command line.

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

workerprocess-0.1.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file workerprocess-0.1.2.tar.gz.

File metadata

File hashes

Hashes for workerprocess-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3c1ec6ee855b385298b1769f828e7946725a3528c85df08f0ab4b769770c3083
MD5 27b290eebce914b8a7c93b3d388edd18
BLAKE2b-256 6a93200a043322be9bee695c0df3cdbb135b686f8ebe601f04ae7c28f24805a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page