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()
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.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13cdb80e83ee63b7e8e023fde7dfab34dc23a7834c8b5784b7510c2771d89f60 |
|
MD5 | 9132b3880ea23c13c34a716f711c9d8b |
|
BLAKE2b-256 | d3423bfffdcf6480b5133990af3553d67f7ee3ab2d25c2fd45a7e8ef8e7331e8 |
Close
Hashes for simple_multiprocessing-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48e7ec5629df8ea8d48fded843909f799c82632e7238f288eabe01b15535053f |
|
MD5 | 59c944b30ba11651cdc8b315a1b97ab2 |
|
BLAKE2b-256 | 049e1b7266856f2a4143aaeb0cf3efdd1a9441d228d061547d5479e839de0fb4 |