Skip to main content

Streamlined multi-threaded process acceleration

Project description

WarpCore logo

warpcore

Code style: black

Streamlined multi-threaded process acceleration

When working with software that needs to be performant, it’s challenging to deal with all the pitfalls of multi-threading while balancing code stability.

Smoothing out the bumps in the road to multi-threading is the primary goal of the project. It’s just that simple.

Installation

OS X, Linux & Windows:

pip install warpcore

Usage Examples

List Operations

  1. Build a list of arguments that will be passed to a designated function.
jobs = []
jobs.append("Picard")
jobs.append("Janeway")
jobs.append("Kirk")
jobs.append("Sisko")
jobs.append("Archer")
  1. Create a function that will iterate over the list:
def do_the_thing(name):
    print(f"Star Fleet Captain {name}")
  1. Create a single-threaded version to test:
for name in jobs:
    do_the_thing(name)
  1. Once that works, convert the for-loop into a warpcore call
warpcore.list_engage(jobs, do_the_thing)

Full example:

from warpcore.engineering import WarpCore

def do_the_thing(name):
    print(f"Star Fleet Captain {name}")

jobs = []
jobs.append("Picard")
jobs.append("Janeway")
jobs.append("Kirk")
jobs.append("Sisko")
jobs.append("Archer")

# Single-threaded operation (for testing/debug)
# for name in jobs:
#     do_the_thing(name)

# Multi-threaded operation (for normal operation)
warpcore = WarpCore()
warpcore.list_engage(jobs, do_the_thing)

Please refer to example0.py and example1.py for basic and more advanced usage examples respectively.

Dictionary Operations

  1. Build a dict of arguments that will be passed to a designated function.
database = {
    "Picard": "USS Enterprise-D",
    "Janeway": "USS Voyager",
    "Kirk": "USS Enterprise-A",
    "Sisko": "Deep Space 9",
    "Archer": "Enterprise NX-01"
}
  1. Create a function that will iterate over the dictionary:

*Note when using dicts, make sure your worker function accepts the key and value as arguments. (See below)

def do_the_thing(key, value):
    print(f"Star Fleet Captain {key} is/was in command of {value}")
  1. Create a single-threaded version to test:
for key, value in database.items():
    do_the_thing(key, value)
  1. Once that works, convert the for-loop into a warpcore call
warpcore.dict_engage(database, do_the_thing)

Full example:

from warpcore.engineering import WarpCore

def do_the_thing(key, value):
    print(f"Star Fleet Captain {key} is/was in command of {value}")

database = {
    "Picard": "USS Enterprise-D",
    "Janeway": "USS Voyager",
    "Kirk": "USS Enterprise-A",
    "Sisko": "Deep Space 9",
    "Archer": "Enterprise NX-01"
}

# Single-threaded operation (for testing/debug)
# for key, value in database.items():
#     do_the_thing(key, value)

# Multi-threaded operation (for normal operation)
warpcore = WarpCore()
warpcore.dict_engage(jobs, do_the_thing)

Meta

Brandon Blackburn – PGP Encrypted Chat @ Keybase

Distributed under the Apache 2.0 license. See LICENSE for more information.

TL;DR: For a human-readable & fast explanation of the Apache 2.0 license visit: http://www.tldrlegal.com/l/apache2

https://github.com/BlackburnHax/warpcore

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

warpcore-1.0.5-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: warpcore-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for warpcore-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8c1dac886889e7e5d58f71f51c760776e8547c2ba1492035980fd83972abdddb
MD5 b8ed09a61f63d52ca5e5a332f8dc9a3f
BLAKE2b-256 31b1ba12307cb57ba273d4fe9d5c010768c0bcd3e58033f832d69a34734fdee4

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