https://github.com/brianpugh/lox
Threading and Multiprocessing made easy.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.7%) to scientific vocabulary
Keywords
concurrency
multiprocessing
multithreading
mutex
semaphore
Last synced: 5 months ago
·
JSON representation
Repository
Threading and Multiprocessing made easy.
Basic Info
Statistics
- Stars: 125
- Watchers: 6
- Forks: 1
- Open Issues: 2
- Releases: 14
Topics
concurrency
multiprocessing
multithreading
mutex
semaphore
Created almost 7 years ago
· Last pushed 7 months ago
Metadata Files
Readme
Changelog
Contributing
Funding
License
Authors
README.rst
.. image:: assets/lox_200w.png
.. image:: https://img.shields.io/pypi/v/lox.svg
:target: https://pypi.python.org/pypi/lox
.. image:: https://readthedocs.org/projects/lox/badge/?version=latest
:target: https://lox.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Threading and multiprocessing made easy.
* Free software: Apache-2.0 license
* Documentation: https://lox.readthedocs.io.
* Python >=3.6
**Lox** provides decorators and synchronization primitives to quickly add
concurrency to your projects.
Installation
------------
pip3 install --user lox
For multiprocessing support, install with the optional extra:
pip3 install --user 'lox[multiprocessing]'
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.
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]
Or, for example, if you aren't allowed to directly decorate the function you
would like multithreaded/multiprocessed, you can just directly invoke the
decorator:
.. code-block:: pycon
>>> # Lets say we don't have direct access to this function
... def foo(x, y):
... return x * y
...
>>>
>>> def my_func():
... foo_threaded = lox.thread(foo)
... for i in range(5):
... foo_threaded.scatter(i, i + 1)
... results = foo_threaded.gather()
... # foo is currently being executed in default 50 thread executor pool
... return results
...
This also makes it easier to dynamically control the number of
thread/processes in the executor pool. The syntax is a little weird, but
this is just explicitly invoking a decorator that has optional arguments:
.. code-block:: pycon
>>> # Set the number of executer threads to 10
>>> foo_threaded = lox.thread(10)(foo)
Easy Multiprocessing
^^^^^^^^^^^^^^^^^^^^
.. code-block:: pycon
>>> 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]
Progress Bar Support (tqdm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: pycon
>>> import lox
>>> from random import random
>>> from time import sleep
>>>
>>> @lox.thread(2)
... def foo(multiplier):
... sleep(multiplier * random())
...
>>> for i in range(10):
>>> foo.scatter(i)
>>> results = foo.gather(tqdm=True)
90%|████████████████████████████████▌ | 9/10 [00:03<00:00, 1.32it/s]
100%|███████████████████████████████████████| 10/10 [00:06<00:00, 1.46s/it]
Owner
- Name: Brian Pugh
- Login: BrianPugh
- Kind: user
- Location: Washington D.C.
- Repositories: 123
- Profile: https://github.com/BrianPugh
Deep Learning Scientist and blockchain enthusiast
GitHub Events
Total
- Create event: 4
- Release event: 1
- Issues event: 2
- Watch event: 34
- Delete event: 2
- Issue comment event: 3
- Push event: 15
- Pull request event: 3
Last Year
- Create event: 4
- Release event: 1
- Issues event: 2
- Watch event: 34
- Delete event: 2
- Issue comment event: 3
- Push event: 15
- Pull request event: 3
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Brian Pugh | b****7@g****m | 158 |
| pyup-bot | g****t@p****o | 84 |
| Brian Pugh | b****h@g****m | 14 |
| Brian Pugh | b****h@p****l | 5 |
Committer Domains (Top 20 + Academic)
geomagical.com: 1
pyup.io: 1
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 2
- Total pull requests: 102
- Average time to close issues: 17 minutes
- Average time to close pull requests: 21 days
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 1.5
- Average comments per pull request: 0.15
- Merged pull requests: 53
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 2
- Average time to close issues: 17 minutes
- Average time to close pull requests: 1 minute
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 3.0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- BrianPugh (1)
- paul-gauthier (1)
Pull Request Authors
- pyup-bot (92)
- BrianPugh (13)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 36,981 last-month
- Total dependent packages: 1
- Total dependent repositories: 1
- Total versions: 23
- Total maintainers: 1
pypi.org: lox
Threading and Multiprocessing for every project.
- Homepage: https://github.com/BrianPugh/lox
- Documentation: https://lox.readthedocs.io/
- License: MIT license
-
Latest release: 1.0.0
published 7 months ago
Rankings
Dependent packages count: 4.8%
Downloads: 5.5%
Stargazers count: 7.5%
Average: 12.4%
Dependent repos count: 21.6%
Forks count: 22.6%
Maintainers (1)
Last synced:
5 months ago
Dependencies
requirements.txt
pypi
- pathos *
- sphinx_rtd_theme *
requirements_dev.txt
pypi
- Sphinx * development
- autoflake * development
- autopep8 * development
- bumpversion * development
- coverage * development
- flake8 * development
- pytest * development
- pytest-benchmark * development
- pytest-mock * development
- pytest-runner * development
- tox * development
- tqdm * development
- twine * development
- watchdog * development
- wheel * development
.github/workflows/deploy.yaml
actions
- actions/cache v4 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/upload-artifact v4 composite
setup.py
pypi