Skip to main content

Threading and Multiprocessing for every project.

Project description

assets/lox_200w.png https://img.shields.io/pypi/v/lox.svg https://travis-ci.com/BrianPugh/lox.svg?branch=master Documentation Status Updates

Threading and multiprocessing made easy.

Lox provides decorators and synchronization primitives to quickly add concurrency to your projects.

Installation

pip3 install –user lox

Features

  • Multithreading: Powerful, intuitive multithreading in just 2 additional lines of code.

  • Multiprocessing: Truly parallel function execution with the same interface as multithreading.

  • Synchronization: Advanced thread synchronization, communication, and resource management tools.

Todos

  • All objects except lox.process are for threads. These will eventually be multiprocess friendly.

  • Chaining of scatter calls to multiple worker pools

Usage

Easy Multithreading

>>> import lox
>>>
>>> @lox.thread(4) # Will operate with a maximum of 4 threads
... def foo(x,y):
...     return x*y
>>> foo(3,4) # normal function calls still work
12
>>> for i in range(5):
...     foo.scatter(i, i+1)
-ignore-
>>> # foo is currently being executed in 4 threads
>>> results = foo.gather() # block until results are ready
>>> print(results) # Results are in the same order as scatter() calls
[0, 2, 6, 12, 20]

Easy Multiprocessing

>>> import lox
>>>
>>> @lox.process(4) # Will operate with a pool of 4 processes
... def foo(x,y):
...     return x*y
>>> foo(3,4) # normal function calls still work
12
>>> for i in range(5):
...     foo.scatter(i, i+1)
-ignore-
>>> # foo is currently being executed in 4 processes
>>> results = foo.gather() # block until results are ready
>>> print(results) # Results are in the same order as scatter() calls
[0, 2, 6, 12, 20]

History

0.5.0 (2019-07-01)

  • New Object: lox.Announcement. Allows a one-to-many thread queue with backlog support so that late subscribers can still get all (or most recent) announcements before they subscribed.

  • New Feature: lox.thread scatter calls can now be chained together. scatter now returns an int subclass that contains metadata to allow chaining. Each scatter call can have a maximum of 1 previous scatter result.

  • Documentation updates, theming, and logos

0.4.3 (2019-06-24)

  • Garbage collect cached decorated object methods

0.4.2 (2019-06-23)

  • Fixed multiple instances and successive scatter and gather calls to wrapped methods

0.4.1 (2019-06-23)

  • Fixed broken workers and unit tests for workers

0.4.0 (2019-06-22)

  • Semi-breaking change: lox.thread and lox.process now automatically pass the object instance when decorating a method.

0.3.4 (2019-06-20)

  • Print traceback in red when a thread crashes

0.3.3 (2019-06-19)

  • Fix bug where thread in scatter of lox.thread double releases on empty queue

0.3.2 (2019-06-17)

  • Fix manifest for installation from wheel

0.3.1 (2019-06-17)

  • Fix package on pypi

0.3.0 (2019-06-01)

  • Multiprocessing decorator. lox.pool renamed to lox.thread

  • Substantial pytest bug fixes

  • Documentation examples

  • timeout for RWLock

0.2.1 (2019-05-25)

  • Fix IndexSemaphore context manager

0.2.0 (2019-05-24)

  • Added QLock

  • Documentation syntax fixes

0.1.1 (2019-05-24)

  • CICD test

0.1.0 (2019-05-24)

  • First release on PyPI.

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

lox-0.5.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

lox-0.5.0-py2.py3-none-any.whl (20.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file lox-0.5.0.tar.gz.

File metadata

  • Download URL: lox-0.5.0.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for lox-0.5.0.tar.gz
Algorithm Hash digest
SHA256 5d788293721e1811e2404657057d9528aa5c3c22f5ec60f6577bf091f26fa212
MD5 1f9caa37ae736bd08f02b8d1ba76c3d0
BLAKE2b-256 f3cb4cd04093911be062673e967f61708aed42c7aa46183b78485d9c8b4d708a

See more details on using hashes here.

File details

Details for the file lox-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: lox-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for lox-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a5ca6d337fac9a0408f3a6427025e38612e184b4b351d09c1c63e826c414f114
MD5 4db846c0074ea76850da72b8cc7103de
BLAKE2b-256 363c42e45424092afb4dd7d9a0d06de4b4cf16a34f9b602c2b7ae2285f808adc

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