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.4.tar.gz
(2.0 kB
view details)
Built Distribution
File details
Details for the file multithreader-1.0.4.tar.gz
.
File metadata
- Download URL: multithreader-1.0.4.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 | 7ef6d55976405e22cd60d1506095997962a2d23aebce35720150961079002c12 |
|
MD5 | c2503c84109cbb512e8f42173c8b1e19 |
|
BLAKE2b-256 | ae8a049595cf327cdfdefc99a869b31fac9eb6b2fa7f4e99aa35fd855ead6df0 |
File details
Details for the file multithreader-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: multithreader-1.0.4-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 | 9ddc4b52794898fccad8c59b9912b3fe365d6b139f57a22d5fd0836264e3bdd2 |
|
MD5 | c40c4df74bc6388f6e0fc7909cf81e78 |
|
BLAKE2b-256 | 12465c5a03d789402bfea3ee488f692f1259fce3538b901285303805687e39c3 |