-1

Ok, so one can write a custom made eventloop over using given asyncio's eventloop (Writing an EventLoop without using asyncio)

Now the question rises is why? Why prefer writing a custom made over asyncio's eventloop?

1
  • I believe it's legacy. asyncio is new in Python standard, and was "usable" before keywords "async" and "await". For exemple, the web framework Tornado can use a non blocking API, without asyncio. But I believe today, the best practice is to use AsyncIO. Commented Dec 14, 2018 at 6:54

1 Answer 1

3

Why prefer writing a custom made over asyncio's eventloop?

Usually you invent something new if existing approach doesn't fit your needs. Or may be if you think you can do things more efficiently or conveniently.

First of all it worth noting that asyncio itself provides multiple event loop implementations. Reason for this is that they built on top of different low-level OS API an can behave differently. You can select (or write your own event loop) that fits your task best.

Sometimes people create their own event loop implementations for better performance. Good example of such case is uvloop.

Sometimes people create event loops on top of other non-asyncio event loops. For example quamash provides event loop on top of Qt. It allows to write asynchronous programs using PyQt.

Sign up to request clarification or add additional context in comments.

1 Comment

While on the topic of alternative event loops, you might want to also mention curio and trio, event loops written without the goal of asyncio compatibility and differing from it in both philosophy and implementation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.