Skip to main content

EventEmitter with gevent

Latest version released on PyPi Test coverage Build status of master branch

This module implements EventEmitter with gevent.

Installation

To install the latest release from pypi:

pip install gevent-eventemitter

Usage

EventEmitter can be used as mixin, or on it’s own. Here is an example as mixin:

from eventemitter import EventEmitter

class MyClass(EventEmitter):
    pass

instance = MyClass()

Registering a callback

def do_stuff():
    print "Hello world!"

instance.on('my event', do_stuff)

instance.emit('my event')

Or as decorator

@instance.on('my event')
def do_stuff():
    print "Hello world!"

With once the callback will be called, you guessed it, only once.

@instance.once('my event')
def do_stuff(var):
    print "Hello %s!" % var

instance.emit('my event', 'Earth')  # arguments can be passed along events
instance.emit('my event')  # do_stuff won't be called
It’s possible to block wait for an event.

If there are event arguments they will be returned as a tuple

my_args = instance.wait_event('my event')
my_args = instance.wait_event('my event', timeout=5)  # wait at most 5seconds

On timeout wait_event will return None, or raise gevent.Timeout if raises=True

my_args = instance.wait_event('my event', timeout=5)
if my_args is None:
    print "Timeout!"

try:
    my_args = instance.wait_event('my event', timeout=5, raises=True)
except gevent.Timeout:
    print "Timeout!"

To remove a callback, or all callbacks.

instance.remove_listener('my event', do_stuff)
instance.remove_all_listeners()                 # absolutely all listeners
instance.remove_all_listeners('my event')       # all listners for the event

Listening for None event will result in catching all events.

Metadata

Release files for gevent-eventemitter 2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gevent-eventemitter 2.1
File Size Uploaded Provenance Actions
gevent-eventemitter-2.1.tar.gz 3.7 kB Without provenance Details for gevent-eventemitter-2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gevent-eventemitter 2.1
File Interpreter ABI Platform Actions
gevent_eventemitter-2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for gevent_eventemitter-2.1-py2.py3-none-any.whl

Total release size: 9.6 kB

Release files / gevent-eventemitter-2.1.tar.gz

Download URL gevent-eventemitter-2.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
00e6e688c6a255f7bdcef1d8c999e0d02d9ab87d3c6ff626e6dc1a09762107f4
BLAKE2b-256 checksum
How to use checksums
1f569e449b380f1e8cf19bedb4564e61a79dcf3971e6204ef08885d5816a9fe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/34.3.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.1

Release files / gevent_eventemitter-2.1-py2.py3-none-any.whl

Download URL gevent_eventemitter-2.1-py2.py3-none-any.whl
Size 5.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
30605a9fbb1f38b2511f188a2e7a1b4e9262f3c13bf810ac5b79cc0ba2900ff7
BLAKE2b-256 checksum
How to use checksums
c7f547f896511ca1fb5dd6e9fa1ba152f9ccc3f892f4d31c8757cfe36c248c8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/34.3.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.1

Security for gevent-eventemitter 2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page