Skip to main content

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.5.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multithreader-1.0.5-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file multithreader-1.0.5.tar.gz.

File metadata

  • Download URL: multithreader-1.0.5.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+

File hashes

Hashes for multithreader-1.0.5.tar.gz
Algorithm Hash digest
SHA256 83868fff44776c5f072821f49405ef405ccb2c7dc674c71cd6ee380f11e6dde8
MD5 448f2f7efe9701db327d98c93b2337d8
BLAKE2b-256 d697120f4541a90c81dc1c07cb1b08171f2dcd64b85efe3e12b52145da9e4e58

See more details on using hashes here.

File details

Details for the file multithreader-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: multithreader-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.154+

File hashes

Hashes for multithreader-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 067cd38d1ef38755a483b61809c088a56e6805a444802fee97acff0d19beb4f4
MD5 30a9a4191ed61c505968e971c3687d23
BLAKE2b-256 d0f1977eb6a3a16a98ece214415db987d3cf19cd9b5277aaaa041dccdec5ddde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page