simple_multiprocessing
Project description
simple_multiprocessing
Description
Execute multiple async tasks (via multiprocessing.Process, or threading.Thread) 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_func(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
tasks = [Task(test_func, i) for i in range(5)]
# via threading
results_via_threading = MultiThread(tasks).solve(timeout=1)
for i, r in enumerate(results_via_threading):
print(i, type(r), r)
# via Multiproccess
results_via_multiprocess = MultiProcess(tasks).solve(timeout=1)
for i, r in enumerate(results_via_multiprocess):
print(i, type(r), r)
Dependencies
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
File details
Details for the file simple_multiprocessing-0.0.15.tar.gz
.
File metadata
- Download URL: simple_multiprocessing-0.0.15.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86c625234bed3f47725ede8154b251b21a558c3224d20dab0bcb90bd31cce721 |
|
MD5 | 062ba822c6a6905d4732ae1887f0dcfe |
|
BLAKE2b-256 | 3dd09ee1ce28bbf3e89ec082853f44b7539edbc3736ccf3f5ad87bf736657613 |
File details
Details for the file simple_multiprocessing-0.0.15-py3-none-any.whl
.
File metadata
- Download URL: simple_multiprocessing-0.0.15-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee91cde0b279d9b2e7a0a88949cbfc882267f660e4683782b9d4805d9a76ca72 |
|
MD5 | e72658953edde50b0d4272e4e2796555 |
|
BLAKE2b-256 | 27b818b431d7bb4fb7963133658fc5d1b8ca759b1e618fbfcd5752126dead2d8 |