File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -333,34 +333,6 @@ Futures are much more versatile and will be marked as done when you say so.
333333In this way, they're the flexible interface for you to make your own conditions
334334for waiting and resuming.
335335
336- ===========================
337- await-ing Tasks and futures
338- ===========================
339-
340- ``Future `` defines an important method: ``__await__ ``. Below is the actual
341- implementation (well, one line was removed for simplicity's sake) found
342- in ``asyncio.futures.Future ``.
343- It's okay if it doesn't make complete sense now, we'll go through it in detail
344- in the control-flow example.
345-
346- ::
347-
348- 1 class Future:
349- 2 ...
350- 3 def __await__(self):
351- 4
352- 5 if not self.done():
353- 6 yield self
354- 7
355- 8 if not self.done():
356- 9 raise RuntimeError("await wasn't used with future")
357- 10
358- 11 return self.result()
359-
360- The ``Task `` class does not override ``Future ``'s ``__await__ `` implementation.
361- ``await ``\ ing a task or future invokes that above ``__await__ `` method and
362- percolates the ``yield `` on line 6 to relinquish control to its caller, which
363- is generally the event loop.
364336
365337========================
366338A homemade asyncio.sleep
You can’t perform that action at this time.
0 commit comments