Skip to main content

A plug n play multithreading interface

Project description

thread6

Simple parallel processing interface for python

Why?

Python's built in parallel processing and threading library is pretty simple to implement but sometimes you just want to chuck data at a function and make it run faster

Requirements

Python 3+

Installation

Quickstart

Use the threaded decorator to turn a method into a threaded method. That's it!

@thread6.threaded()
def threaded_print():
    print("")
    return 1

Alternatively, use run_threaded function

thread6.run_threaded(threaded_print)

Both the threaded decorator and run_threaded method will return an instance of ResultThread. This allow you to optionally wait for the function to finish executing and get the return value. To get the return value, use .await_output()

result = threaded_print()
result.await_output()  # this will return 1

If you have a function that needs to execute on a large list of data, use run_chunked

def update_items(items):
    ...

items = [...]
thread6.run_chunked(update_items, items)

.await_output() also work with run_chunked but will return a list of return values instead

Usage

Todo

  • threaded function decorator
  • run something in a separate thread function
  • split data into chunk and run in separate threads
  • add way for errors to fail loudly
  • auto spawn to run fx on a set of data
  • explore multi processing?

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

thread6-0.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

thread6-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file thread6-0.2.0.tar.gz.

File metadata

  • Download URL: thread6-0.2.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for thread6-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ed7a398e7f4d7fcedfcbc689ed3ef11179b040ead277ba15a6b316ff7d4d1b81
MD5 7b3d9b27b3e686a992e607541c0fc8a8
BLAKE2b-256 39f2cd7b53367c00a0e4a37c53c5b18007a50fb66f19331699c894c918230b8b

See more details on using hashes here.

File details

Details for the file thread6-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: thread6-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.4

File hashes

Hashes for thread6-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 618037241f4a486940ca8e9c1f8cb0a476473c6036dc10a717c1ff5fbdabd7fc
MD5 d63080b4d13e6ff0edfc91f3585df86d
BLAKE2b-256 f0463a1220d4f933c1a2b4eba2d0d9306cac0ba0d758a9c3958a4213edba6866

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