|gwillz 044f80d8ce updated test imports and CI to reflect py2 compat||3 years ago|
|avent||3 years ago|
|tests||3 years ago|
|.gitignore||4 years ago|
|.gitlab-ci.yml||3 years ago|
|MANIFEST.in||4 years ago|
|README.md||3 years ago|
|setup.py||3 years ago|
|test.py||4 years ago|
This library provides a simple event interface for threaded environments. It's primary aim is to keep processing of events within their respective threads. Although 'threads' in Python are mostly artificial, considering the GIL, this library is still beneficial.
Avents ties threads to object instances. Therefore threads should target the
loop() function of an
Abject. If implementing threads in an existing thread
loop, then include a
if self._handlEvents(): break call.
Any given event handler will be executed within an Abject's thread loop. Avents
discovers this by using the instance of a method-function or the first parameter
fire() function. If neither can be found, the handler is put on the
_sub_main event stack that is executed in the
run_forever() helper function.
This library also includes a barebones, async-less,
Event class from which
Avent inherits its core functionality.
This is a slight modification of the
Event class to allow any number of args
for handlers and the
fire() function without errors.
from avent import Fluid as Event ev = Event() ev += lambda a, b, c: print(a,b,c) ev += lambda a: print(a) ev.fire(1, 2) # handler 1 => "1, 2, None" # handler 2 => "1"
This is the polar opposite of a 'Fluid' event. Permissible arguments are specific
on init and handlers and events will throw
ArgsError whenever the rules are
from avent import Strict as Event ev = Event('a', 'b') ev += lambda a,b,c: print(a,b,c) # => throws ArgsError ev += lambda a: print(a) # => throws ArgsError ev.fire(1) # => throws ArgsError ev.fire(1, 2, 3) # => throws ArgsError # acceptable ev += lambda a,b: print(a,b) ev.fire(1,2)
Copyright (c) 2017 MK2 Engineering Solutions Pty. Ltd. All Rights Reserved.