Skip to main content

A small package for simple multiprocessing

Project description

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]

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

ez_task-0.1.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ez_task-0.1.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ez_task-0.1.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.7 Darwin/21.0.1

File hashes

Hashes for ez_task-0.1.2.tar.gz
Algorithm Hash digest
SHA256 df3f9c35a575ee56ed2c0b056ca922f518181d7fba505a3fd93cc7b09b20d0fb
MD5 99c97bb8cdb67751ad63554d09ff72ab
BLAKE2b-256 9efd1e3111b823e14fa836d0a9c6a0e2ed80fe92cce22965106e68a55598085f

See more details on using hashes here.

File details

Details for the file ez_task-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ez_task-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.7 Darwin/21.0.1

File hashes

Hashes for ez_task-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbf310e4b0d47b1379b97fd6f81e112c23504bfffddf68ea2a0e8dc28b8e80a7
MD5 bd78a1a1f34764f03d635456dbdff34a
BLAKE2b-256 6183bf80e4a189dddb417e8cc338b6b74e3c10af26505f914726236766854733

See more details on using hashes here.

Supported by

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