Skip to content

Commit b08ab3c

Browse files
committed
Update FASTPOLL.md
1 parent 9101ea3 commit b08ab3c

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

FASTPOLL.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,29 @@ This behaviour may be desired where short bursts of fast data are handled.
225225
Otherwise drivers of such hardware should be designed to avoid hogging, using
226226
techniques like buffering or timing.
227227

228-
The version also supports an `implementation` namedtuple with the following
229-
fields:
230-
* `name` 'fast_io'
231-
* `variant` `standard`
232-
* `major` 0 Major version no.
233-
* `minor` 100 Minor version no. i.e. version = 0.100
234-
235-
The `variant` field can also contain `lowpower` if running that version.
228+
The version also supports an `version` variable containing 'fast_io'. This
229+
enables the presence of this version to be determined at runtime.
230+
231+
It also supports a `got_event_loop()` function returning a `bool`: `True` if
232+
the event loop has been instantiated. The purpose is to enable code which uses
233+
the event loop to raise an exception if the event loop was not instantiated.
234+
235+
```python
236+
class Foo():
237+
def __init__(self):
238+
if asyncio.got_event_loop():
239+
loop = asyncio.get_event_loop()
240+
loop.create_task(self._run())
241+
else:
242+
raise OSError('Foo class requires an event loop instance')
243+
```
244+
This avoids subtle errors:
245+
```python
246+
import uasyncio as asyncio
247+
bar = Bar() # Constructor calls get_event_loop()
248+
# and renders these args inoperative
249+
loop = asyncio.get_event_loop(runq_len=40, waitq_len=40)
250+
```
236251

237252
###### [Contents](./FASTPOLL.md#contents)
238253

0 commit comments

Comments
 (0)