Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Off-topic]Ghost of Twisted - sippy_async - monkey patch to support running on anyio #44

Open
space88man opened this issue May 17, 2021 · 0 comments

Comments

@space88man
Copy link

space88man commented May 17, 2021

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 and EventDispatcher 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant