ez-task-0.1.2
توضیحات
A small package for simple multiprocessing
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | ez-task-0.1.2 |
| نام | ez-task |
| نسخه کتابخانه | 0.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Chris Moyer |
| ایمیل نویسنده | chris@telemetry.fm |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/ez-task/ |
| مجوز | MIT |
# ez-task - simple python multiprocessing
ez-task wraps the standard Python multiprocessing library to simplify the management and usage of multiple long-running processes.
ez-task is designed for low-latency applications.
## Installation
> `pip3 install --no-deps ez-task`
# Usage
## Using TaskManager
```
from ez_task.manager import TaskManager
import time
def foo():
time.sleep(1)
return 'Foo Call'
def bar(text):
time.sleep(2)
return text
def baz(text, key = 'key'):
time.sleep(3)
return f'{text} {key}'
with TaskManager() as manager:
foo_task, bar_task, baz_task = manager.define_task_set(foo, bar, baz)
# Execute tasks concurrently
foo_task.run()
bar_task.run('bar')
baz_task.run('baz', key='booz')
# Sychronously block for output
print('foo task:', foo_task.get_result()) # foo task: foo task Foo
print('bar task:', bar_task.get_result()) # bar task: bar
print('baz task:', baz_task.get_result()) # baz task: baz booz
# Total time taken is 3 seconds
```
## Using Task Directly
```
def foo(a, b):
time.sleep(2)
return a + b
task = Task(foo)
for i in range(10):
task.run(i, i*2)
results = task.get_all_results()
print(results) # [0, 3, 9, 12]
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl ez-task-0.1.2:
pip install ez-task-0.1.2.whl
نصب پکیج tar.gz ez-task-0.1.2:
pip install ez-task-0.1.2.tar.gz