[Python-Dev] microthreading vs. async io (original) (raw)
Joachim König-Baltes joachim.koenig-baltes at emesgarten.de
Thu Feb 15 16:51:30 CET 2007
- Previous message: [Python-Dev] generic async io
- Next message: [Python-Dev] microthreading vs. async io
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Joachim König-Baltes wrote:
The problem solved by this approach is to allow a number of cooperating threads to wait for an event without the need to busy loop or block by delegating the waiting to a central instance, the scheduler. How this efficient waiting is implemented is the responsability of the scheduler, but the schedular would not do the (possibly blocking) io operation, it would only guaranty to continue a task, when it can do an IO operation without blocking.
From the point of view of the task, it only has to sprinkle a number of wait(...) calls before doing blocking calls, so there is no need to use callbacks or writing the inherently sequential code upside down. That is the gain I'm interested in.
The style used in asyncore, inheriting from a class and calling return in a method and being called later at a different location (different method) just interrupts the sequential flow of operations and makes it harder to understand. The same is true for all other strategies using callbacks or similar mechanisms.
All this can be achieved with a multilevel yield() that is hidden in a function call. So the task does a small step down (wait) in order to jump up (yield) to the scheduler without disturbing the eye of the beholder.
Joachim
- Previous message: [Python-Dev] generic async io
- Next message: [Python-Dev] microthreading vs. async io
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]