Skip to main content

A module that makes multiprocessing easy.

Project description

mplite

A light weight wrapper for pythons multiprocessing module that makes multiprocessing easy.

In case anyone is looking for a very easy way to use multiprocessing with args and kwargs, here is a neat wrapper as mplite:

The test is also the showcase:

from mplite import TaskManager, Task
import time

# first create the function that each cpu should work on individually.
def f(*args, **kwargs):
    print(args, kwargs)
    time.sleep(args[0])
    return args[0]

# Next create the main function you'd like to run everything from:
def main():
    tasks = []   # create a tasklist and populate it with tasks
    for n in list(range(10))*5:
        t = Task(f, *(n/10,), **{'hello': n})  
        tasks.append(t)

    with TaskManager() as tm:
        results = tm.execute(tasks)

if __name__ == "__main__":
    main()

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

mplite-1.0.2.tar.gz (3.7 kB view hashes)

Uploaded Source

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