Hank is an asynchronous job processing and orchestration system.
- Dispatching of work orders for individual jobs
- Orchestration of work flows of multiple work orders
- Support for managing large batch processes from running jobs
from hank import Dispatcher, LocalMemoryWorkQueue, LocalMemoryResultStore, task
@task
def arithmetic_task(x, y):
return x + y
dispatcher = Dispatcher()
if __name__ == '__main__':
result_store = LocalMemoryResultStore()
dispatcher.add_queue(LocalMemoryWorkQueue())
dispatcher.add_result_store(result_store)
dispatcher.add_job(arithmetic_task)
result = dispatcher.send(arithmetic_task.work_order(2, 3))
dispatcher.dispatch_until_exhausted()
print(result.wait())
import sys
from hank import Dispatcher, job, RedisWorkQueue, RedisResultStore
@job
def arithmetic_job(work_order):
work_order.dispatcher.store_result(sum(work_order.params['args']))
dispatcher = Dispatcher()
if __name__ == '__main__':
result_store = RedisResultStore('redis://localhost:6379/1')
dispatcher.add_queue(RedisWorkQueue('redis://localhost:6379/0'))
dispatcher.add_result_store(result_store)
dispatcher.add_job(arithmetic_job)
if sys.argv[1] == 'worker':
dispatcher.dispatch_forver()
else:
result = dispatcher.send(
arithmetic_job.work_order(
args=[int(i) for i in sys.argv[1:]]
)
)
print(result.wait())
Stable Release: pip install hank
Development Head: pip install git+https://github.com/npilon/hank.git
For full package documentation please visit npilon.github.io/hank.
See CONTRIBUTING.md for information related to developing the code.
-
pip install -e .[dev]
This will install your package in editable mode with all the required development dependencies (i.e.
tox
). -
make build
This will run
tox
which will run all your tests in both Python 3.7 and Python 3.8 as well as linting your code. -
make clean
This will clean up various Python and build generated files so that you can ensure that you are working in a clean environment.
-
make docs
This will generate and launch a web browser to view the most up-to-date documentation for your Python package.
Apache Software License 2.0