Execute Python functions with multithreading.
Project description
Overview
Execute Python functions with multithreading.
Usage
Installation:
pip3 install multithreader
# or
python3 -m pip install multithreader
Example:
def test_function(
iterator,
items
) -> int:
"""Sum two numbers."""
print(iterator)
sleep(1)
return items['a'] + items['b']
# Import multithreader.
from multithreader import threads
# Define arguments.
items = {
'a': 1,
'b': 2
}
# Define iterators.
iterators = [1, 2, 3, 4, 5]
# Execute function with multithreading.
results = threads(
test_function,
iterators,
items,
thread_num=int(sys.argv[1])
)
# Print results.
print(results)
Full Example
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
multithreader-1.0.3.tar.gz
(2.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multithreader-1.0.3.tar.gz.
File metadata
- Download URL: multithreader-1.0.3.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.4.109+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823e7908b80d1a75ad3105e9454a14f7b0151b54e43c6e50a3c6a0dd75a6ceeb
|
|
| MD5 |
77feeeb8bca31054af886c355bc3b0a9
|
|
| BLAKE2b-256 |
63ad59b38b6c691c717ec34b0fa20697840a4818cfce9b5997699aa9c76f87f0
|
File details
Details for the file multithreader-1.0.3-py3-none-any.whl.
File metadata
- Download URL: multithreader-1.0.3-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.4.109+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378be237c7155fa63789f14855b3115885eb4a7cee7f963d8b8114eb68711ef2
|
|
| MD5 |
5c5b454d21b1e6c2f3c06f06fa0a6f17
|
|
| BLAKE2b-256 |
153142f0910b068a64f4e06d606fe6565c035fa17cff876fedf713b50b209eb5
|