File tree 1 file changed +23
-8
lines changed
1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -225,14 +225,29 @@ This behaviour may be desired where short bursts of fast data are handled.
225
225
Otherwise drivers of such hardware should be designed to avoid hogging, using
226
226
techniques like buffering or timing.
227
227
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
+ ```
236
251
237
252
###### [ Contents] ( ./FASTPOLL.md#contents )
238
253
You can’t perform that action at this time.
0 commit comments