ConcurrentEvents
.. image:: https://gitlab.com/Reggles44/concurrentevents/badges/master/pipeline.svg :alt: pipeline status :target: https://gitlab.com/Reggles44/concurrentevents/-/commits/master
.. image:: https://gitlab.com/Reggles44/concurrentevents/badges/master/coverage.svg :alt: coverage report :target: https://gitlab.com/Reggles44/concurrentevents/-/commits/master
.. image:: https://readthedocs.org/projects/concurrentevents/badge/?version=latest :target: https://concurrentevents.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
ConcurrentEvents is a light weight event system and threading tools build around the concurrent futures library.
The aim of this project is to create an extremely simple and generic event system as well as tools to monitor and use it effectively.
The focus of this project is based around the ConcurrentEvents.EventManager, ConcurrentEvents.EventHandler, ConcurrentEvents.Event classes and ConcurrentEvents.Catch decorator to create a simple and safe way to do multi-threading through an event framework.
Installation
ConcurrentEvents should be installed through pip on python3.5 or higher
.. code-block:: bash
python -m pip install ConcurrentEvents
Usage
ConcurrentEvents is used similar to other event systems where by decorators are used to map functions to events.
This simple example shows a hello world run through the event system but catching the Start event
.. code-block:: python
from ConcurrentEvents import EventManager, catch, Start
@catch(Start)
def hello_world():
print("Hello World")
EventManager().start()
A more complicated example might involve having one event trigger more.
In the following example a custom Event is created to handle outputting counting.
Additionally the CountingEventHandler class is made as a subclass of EventHandler so that it can use the build in functionality of firing and canceling events.
.. code-block:: python
from ConcurrentEvents import EventManager, EventHandler, catch, Start, Event
class CountEvent(Event):
pass
class CountingEventHandler(EventHandler):
@catch(Start)
def start_counting(self):
for i in range(10):
self.fire(CountEvent(i))
@catch(CountEvent)
def print_count(self, i):
print(i)
EventManager().start()
Using the same example of counting there is also functionality to cancel an event or simply trigger exit.
The following code will cancel when i is equal to 5.
At the same time, if i is equal to 8 the exit event will fire which stops all functionality and goes to cleanup.
.. code-block:: python
from ConcurrentEvents import EventManager, EventHandler, catch, Start, Event, Exit
class CountEvent(Event):
pass
class CountingEventHandler(EventHandler):
@catch(Start)
def start_counting(self):
for i in range(10):
self.fire(CountEvent(i))
if i == 5:
self.cancel()
if i == 8:
self.fire(Exit())
@catch(CountEvent)
def print_count(self, i):
print(i)
EventManager().start()
Metadata
Release files for ConcurrentEvents 1.12.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ConcurrentEvents-1.12.5.tar.gz | 7.1 kB | Without provenance | Details |
Release files / ConcurrentEvents-1.12.5.tar.gz
| Download URL | ConcurrentEvents-1.12.5.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6747ca59b9b88bf1ac975cb3d0d6fc83147a356549aa90b3c8ff2b0107d7395e
|
|
BLAKE2b-256 checksum How to use checksums |
c2c31bef7d4effb1b1057b5700ad541041f247c6c88697f5dd6d3fa56cbff054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
|
Security for ConcurrentEvents 1.12.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.