<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/tests/basics/generator_pend_throw.py, branch 6.0.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.0.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.0.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2017-12-19T04:02:34+00:00</updated>
<entry>
<title>tests/basics/generator_pend_throw: Add test for just-started generator.</title>
<updated>2017-12-19T04:02:34+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-19T04:01:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=8e6113a18808792c5d1eb30e54bb0a1694bb4042'/>
<id>urn:sha1:8e6113a18808792c5d1eb30e54bb0a1694bb4042</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/objgenerator: Allow to pend an exception for next execution.</title>
<updated>2017-12-15T18:20:36+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2017-10-21T09:13:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=63644016669c173190c71d39fb33ad9502fe2b0f'/>
<id>urn:sha1:63644016669c173190c71d39fb33ad9502fe2b0f</id>
<content type='text'>
This implements .pend_throw(exc) method, which sets up an exception to be
triggered on the next call to generator's .__next__() or .send() method.
This is unlike .throw(), which immediately starts to execute the generator
to process the exception. This effectively adds Future-like capabilities
to generator protocol (exception will be raised in the future).

The need for such a method arised to implement uasyncio wait_for() function
efficiently (its behavior is clearly "Future" like, and normally would
require to introduce an expensive Future wrapper around all native
couroutines, like upstream asyncio does).

py/objgenerator: pend_throw: Return previous pended value.

This effectively allows to store an additional value (not necessary an
exception) in a coroutine while it's not being executed. uasyncio has
exactly this usecase: to mark a coro waiting in I/O queue (and thus
not executed in the normal scheduling queue), for the purpose of
implementing wait_for() function (cancellation of such waiting coro
by a timeout).
</content>
</entry>
</feed>
