Skip to main content

python events non-blocking

Project description

PypiDownloads pythonversions Code Climate Codecov Travis License


python basic events send non-blocking


pip install basicevents

Link pypi:


# recommeded check all examples
from basicevents import (subscribe, send_thread, send_queue,
                         send_blocking, add_subscribe, send)

def example(*args, **kwargs):
    print "recv signal, values:", args, kwargs

def example2(*args, **kwargs):
    print "manual subscribe"

# manual subscribe
add_subscribe("pepito", example2)

# add to queue signals (non-blocking)
send("pepito", 1, 2, 3, example="added queue")

# add to queue signals (non-blocking)
send_queue("pepito", 1, 2, 3, example="added queue")

# create new thread for this request (non-blocking)
send_thread("pepito", 1, 2, 3, example="new thread")

# This is blocking
send_blocking("pepito", 1, 2, 3, example="blocking")



@subscribe(name_event) With this decorator you can subscribe to all events that are sent to name_event.

manual subscribe add_subscribe(name_event, function)

  • added in queue (non-blocking)

send_queue(name_event, *args, **kwargs)

  • run in new thread (non-blocking)

send_thread(name_event, *args, **kwargs)

  • run blocking (blocking)

send_blocking(name_event, *args, **kwargs)

  • Note: Currently running as thread to allow sharing of memory, if you want an event to use more CPU (cores), you can run processes within the event.

Attributes events

  • events.subs


{'juanito': [<function __main__.example2>],
 'pepito': [<function __main__.example>]}
  • events.queue

return queue

queue is processed automatically and do not need to access this attribute, but if you want you can use

  • events.timeout

return int

It is the timeout of the get request queue. When it reaches the timeout check the MainThread is alive, if so wait to get back, if not, it sends a signal to the EventThread. You can modify it if you wish.

from basicevents import events
events.timeout = 1
  • events.logger

return function

You can change the function that is executed when an exception occurs. Uses default print You can modify it if you wish.

from basicevents import events
events.logger = function
  • events.send

return function

You can change the function send (It is a link). default is events.send_queue

from basicevents import events
events.send = events.send_blocking # or other functions
  • these parameters are too, have documented above:
add_subscribe, send, send_queue, send_thread, send_blocking


1.2.5 (2016-06-15)

  • Fix

1.2.4 (2015-10-15)

  • Fix support python 3

1.2.3 (2015-10-14)

  • Remove 3.2 support
  • Prepare travis

1.2.2 (2015-10-14)

  • Fix readme

1.2.1 (2015-10-14)

  • Remove bad examples
  • Update readme

1.2.0 (2015-09-22)

  • You can change the method that executes when an exception occurs
  • Remove deprecated functions
  • Send internally calls send_queue
  • Official support python 3.5.0
  • Permit change default send

1.1.3 (2015-08-14)

  • Fix bug in add_subcribe

1.1.1 (2015-08-14)

  • Try fix changelog in pypi

1.1.0 (2015-08-14)

  • Refactor code
  • Added new functions: send_queue, send_thread, send_blocking, add_subscribe

1.0.2 (2015-08-14)

  • increase performance function send (19%+)
  • increase performance subscribe (2%+)

1.0.1 (2015-08-13)

  • fix pip install basicevents

1.0.0 (2015-08-13)

  • Now you can run blocker way events
  • break compatibility function send (check documentation)

0.1.5 (2015-08-12)

  • update documentation

0.1.4 (2015-08-12)

  • update documentation
  • remove instant key in kwargs

0.1.3 (2015-08-12)

  • Added changelog
  • Auto convert md to rst in

Project details

Download files

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

Files for basicevents, version 1.2.5
Filename, size File type Python version Upload date Hashes
Filename, size basicevents-1.2.5.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page