-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaiohndchain.html
127 lines (108 loc) · 10.8 KB
/
aiohndchain.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package aiohndchain</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>aiohndchain</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/lib/python3.10/site-packages/aiohndchain/__init__.py">/usr/lib/python3.10/site-packages/aiohndchain/__init__.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="aiohndchain.html#AIOHandlerChain">AIOHandlerChain</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AIOHandlerChain">class <strong>AIOHandlerChain</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AIOHandlerChain">AIOHandlerChain</a>(*, event: Optional[asyncio.locks.Event] = None, lock: Optional[asyncio.locks.Lock] = None, cancellable=True)<br>
<br>
An implementation of event, but more advanced than regular asyncio.Event.<br>
Before emitting an underlying asyncio.Event, handler chain is executed,<br>
and if just one handler returns False, other handlers won't be executed<br>
If one handler returns True, all handlers will be executed regardless if<br>
next handlers returns False.<br>
Also possible to wait on the event before the handlers called, or after<br>
the handlers. There are two relying asyncio.Condition that are triggered<br>
during emitting.<br>
This class is callable, producing a coroutine for emitting an event<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt>async <a name="AIOHandlerChain-__call__"><strong>__call__</strong></a>(self, *args, **kwargs) -> bool</dt><dd><tt>Shorthand for self.<a href="#AIOHandlerChain-emit">emit</a>(*args, **kwargs)</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-__init__"><strong>__init__</strong></a>(self, *, event: Optional[asyncio.locks.Event] = None, lock: Optional[asyncio.locks.Lock] = None, cancellable=True)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-add_handler"><strong>add_handler</strong></a>(self, afunc: Callable[[Any], Optional[Coroutine[Any, Any, Any]]]) -> bool</dt><dd><tt>Add callable or a coroutine function to this handler chain.<br>
Return True if successful, False otherwise</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-debug_print"><strong>debug_print</strong></a>(self, msg: str)</dt></dl>
<dl><dt>async <a name="AIOHandlerChain-emit"><strong>emit</strong></a>(self, *args, **kwargs) -> bool</dt><dd><tt>Execute the handler chain and proceed with underlying event trigger<br>
in case of successful execution. Also triggers other tasks that are<br>
waiting for this event with self.<a href="#AIOHandlerChain-wait_and_handle">wait_and_handle</a>()<br>
Before acquiring the lock, it waits until this lock is completely unlocked.<br>
Note: this function will block until all the handlers are executed.</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-emit_and_handle"><strong>emit_and_handle</strong></a>(self, *args, before=False, kwargs: Optional[dict] = None) -> AsyncGenerator[Any, Callable[[Optional[bool]], Tuple[bool, list, dict]]]</dt><dd><tt>Unlike <a href="#AIOHandlerChain-wait_and_handle">wait_and_handle</a>(), it doesn't block until an event occurs. Instead, it emits<br>
an event and handles it in some way when the handlers are not necessarily required<br>
to be triggered. Using this way of event emission gives an opportunity to determine<br>
whether or not this event emission is successful.<br>
Returns a handle which works in the same way as by <a href="#AIOHandlerChain-wait_and_handle">wait_and_handle</a>()</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-isCancellable"><strong>isCancellable</strong></a>(self) -> bool</dt><dd><tt>Return True or False whether or not this handler chain is cancellable.<br>
This is determined at the <a href="builtins.html#object">object</a>'s creation as cancellable keyword-only argument.</tt></dd></dl>
<dl><dt>async <a name="AIOHandlerChain-on_error"><strong>on_error</strong></a>(self, exc: Exception, *args, **kwargs)</dt><dd><tt>Executed by <a href="#AIOHandlerChain-emit">emit</a>() in case of an exception in it</tt></dd></dl>
<dl><dt>async <a name="AIOHandlerChain-on_failure"><strong>on_failure</strong></a>(self, *args, **kwargs)</dt><dd><tt>Executed by <a href="#AIOHandlerChain-emit">emit</a>() in case of cancellation</tt></dd></dl>
<dl><dt>async <a name="AIOHandlerChain-on_handler_error"><strong>on_handler_error</strong></a>(self, hndid: int, exc: Exception, *args, **kwargs)</dt><dd><tt>Executed by <a href="#AIOHandlerChain-emit">emit</a>() in case if one of the handlers fails to execute</tt></dd></dl>
<dl><dt>async <a name="AIOHandlerChain-on_success"><strong>on_success</strong></a>(self, *args, **kwargs)</dt><dd><tt>Executed by <a href="#AIOHandlerChain-emit">emit</a>() in case of successful execution</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-remove_handler"><strong>remove_handler</strong></a>(self, afunc: Callable) -> bool</dt><dd><tt>Remove coroutine function from this handler chain.<br>
Return True if successful, False otherwise</tt></dd></dl>
<dl><dt><a name="AIOHandlerChain-wait_and_handle"><strong>wait_and_handle</strong></a>(self, *, before=False) -> AsyncGenerator[Any, Callable[[Optional[bool]], Tuple[bool, list, dict]]]</dt><dd><tt>Blocks until this event emits and returns a context manager with handle after<br>
the handler chain.<br>
The handle of returned context manager is callable: it returns a tuple with<br>
3 values: bool, list, dict<br>
First is True if this event is not cancelled, False otherwise<br>
The handle can set the state of the execution: pass False to cancel this event,<br>
and True to force this event to be dispatched successfully.<br>
Others are positioned arguments and keyword arguments passed by <a href="#AIOHandlerChain-emit">emit</a>().<br>
If before=True, waits until this event emits before executing event handlers,<br>
in this case when False is passed into handle, an entire handler chain won't<br>
be executed and this event will be cancelled.</tt></dd></dl>
<dl><dt>async <a name="AIOHandlerChain-wait_for_successful"><strong>wait_for_successful</strong></a>(self)</dt><dd><tt>Blocks until this event emits successfully.<br>
Invokes wait() method on underlying event.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>Any</strong> = typing.Any<br>
<strong>AsyncGenerator</strong> = typing.AsyncGenerator<br>
<strong>Callable</strong> = typing.Callable<br>
<strong>Coroutine</strong> = typing.Coroutine<br>
<strong>MutableSequence</strong> = typing.MutableSequence<br>
<strong>Optional</strong> = typing.Optional<br>
<strong>Tuple</strong> = typing.Tuple</td></tr></table>
</body></html>