b2bua
b2bua copied to clipboard
[Off-topic]Ghost of Twisted - sippy_async - monkey patch to support running on anyio
Introducing sippy_async: a monkey patch to run the event loop over anyio 3, which means that the loop will support asyncio or trio.
I realised that this repo had moved from Twisted to a hand-crafted libelperiodic loop, but...
if you are using async python, I have an experimental monkey patch to support running the
event loop on asyncio/trio via anyio. Basic tests that pass: Timeout
, Udp_server
.
# runs the Timeout / Udp_server testsuites under anyio
python -m sippy_async
Implementation notes:
- does not use threads and the UDP server is implemented with anyio classes
-
ED2.callFromThread()
is not implemented as the network servers run on the event loop - not all methods of
Udp_server
andEventDispatcher
are implemented; only enough to run simple B2BUA scripts and some tests - anyio has sync/async-type queues("memory object streams"): this enables callbacks that require async functionality ( UDP data transmission, timeouts) to work without async creep; no function signatures are changed
- the curio async framework is not supported as this restriction is imposed by anyio 3
The pro would be that if you want to write your B2BUA scripts with async python you won't need to run two event loops.