Developing
Project description
Python Worker Dispatcher
A flexible task dispatcher for Python with multiple threading or processing control
Features
-
Tasks Dispatching to managed worker
-
Elegant Interface for setup and use
OUTLINE
DEMONSTRATION
Use 20 theads concurrently to dispatch tasks for HTTP reqeusts
import worker_dispatcher
import requests
def each_task(config, task_id: int, task_data):
response = requests.get(config['my_endpoint'] + task_data)
return response
responses = worker_dispatcher.start({
'task': {
'list': ['ORD_AH001', 'ORD_KL502', '...' , 'ORD_GR393'],
'callback': each_task,
'config': {
'my_endpoint': 'https://your.name/order-handler/'
},
},
'worker': {
'number': 20,
}
})
Utilizes all CPU cores on the machine to compute tasks.
import worker_dispatcher
def each_task(config, task_id: int, task_data):
result = sum(task_id * i for i in range(10**9))
return result
if __name__ == '__main__':
results = worker_dispatcher.start({
'task': {
'list': 10,
'callback': each_task,
},
'worker': {
'multiprocessing': True
}
})
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
Built Distribution
Close
Hashes for worker_dispatcher-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1032eacfb332622dfbba8f617833724e63742cdcb20aabc5660ece6060ded9c |
|
MD5 | f128126ce1dc919dc95dddcce46ff6f7 |
|
BLAKE2b-256 | 7cf7267d7aba1a0873cc722abfc2646bddafd48fc6e1b9059bdca798a35e5d8c |