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.2.tar.gz
(1.9 kB
view details)
Built Distribution
File details
Details for the file multithreader-1.0.2.tar.gz
.
File metadata
- Download URL: multithreader-1.0.2.tar.gz
- Upload date:
- Size: 1.9 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 | 528e1f2b03fa0857f707b6c42e30e0bbe2f08fef290f02e7f06d80cb164ba256 |
|
MD5 | 94e2df0b09d3540e6b318e420083f0fb |
|
BLAKE2b-256 | 757e896215d1f6bccae3b9544790eab4f40555c9b1e3ddd7d297cdd138a62e0f |
File details
Details for the file multithreader-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: multithreader-1.0.2-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 | d0f1f7bf1dc441857b71647483891c6f2f17a64616b992f1c56c78fae9619440 |
|
MD5 | 4ffe0591fe69b3ef8634abf4a27ff929 |
|
BLAKE2b-256 | 5d113908242fbe68ecc20b809fc0880e3b607508e2764708011a83f3c64cd6ac |