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

Uploaded Source

Built Distribution

multithreader-1.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: multithreader-1.0.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure

File hashes

Hashes for multithreader-1.0.1.tar.gz
Algorithm Hash digest
SHA256 21eca821265784b00e046517d092094cafdccb0437ec75afd3cc3c2fc0e78107
MD5 8ba83f115ec4a08ed00a486261a63fc7
BLAKE2b-256 091aea6fafeb162a7fc2f070b00a55c53a9d9acdca4b4f20f986fe9083dce6e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multithreader-1.0.1-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.12.1 Linux/6.2.0-1018-azure

File hashes

Hashes for multithreader-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0317c154d3508fa0f062b18d4f719e17261973fa1dd193bb00aa1c2a6b3ce767
MD5 790f7d731b4b2bab867ff2cc1f8b66f8
BLAKE2b-256 f4fc775fe1f400287b234c07d95d2065e460e6b117033f715da1c9cf0591a562

See more details on using hashes here.

Supported by

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