execute multiple async tasks as simple as possible
Project description
simple_multiprocessing
Description
execute multiple async tasks (via multiprocessing.Process, or threadingThread) as simple as possible
Install
pip install simple_multiprocessing
# or
pip3 install simple_multiprocessing
Usage
from simple_multiprocessing import MultiThread, MultiProcess, Task
import random, time
def test(i: int) -> float:
print('started:', i)
start = time.time()
start / i
if random.random() < 0.5:
while True:
time.sleep(0.01)
res = time.time() - start
return res#time.time() - start
tasks = [Task(test, i) for i in range(5)]
[print(i, type(r), r) for i, r in enumerate(MultiThread(tasks).solve(timeout=1))]
[print(i, type(r), r) for i, r in enumerate(MultiProcess(tasks).solve(timeout=1))]
Project details
Release history Release notifications | RSS feed
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 simple_multiprocessing-0.0.13.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5555ade32edfe87859bef7803c67674dbf8de812dd78513c1ee7f0661076e74 |
|
MD5 | 09374b1dfa33609f5fb65c14ab21bdfc |
|
BLAKE2b-256 | c72dda0ea10a943f8139cf799c7df0f33f4c1ce24122732217acd18fc64f6820 |
Close
Hashes for simple_multiprocessing-0.0.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737517cf51828aa3a747fe835b5b548a3406cb379a4a8886d583b3ffa74db950 |
|
MD5 | 5fc1b0c1e53caf1480a16acc1d9d1ad5 |
|
BLAKE2b-256 | 116185563619e288823b25db7e12b6faad3456ffbd7fa8e7dc0c169240ca3961 |