chiark / gitweb /
python: Refactoring of I/O events and suchlike.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 8 May 2010 13:46:52 +0000 (14:46 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 9 May 2010 14:07:37 +0000 (15:07 +0100)
commit690a6ec147f76213263b58a8a7fd82b28dde349a
treedd8c66bcc5ad5ac1841db365ae9b002cc74933aa
parente41b17c85e858097cf8c077287c4744dd139f3b5
python: Refactoring of I/O events and suchlike.

There are a number of problems with the current arrangement.

  * The service manager main loop is tied to getting I/O events through
    mLib.  There's a new service coming up which wants to collect D-Bus
    signals, and that involves using the glib event loop instead.

  * Some services seem to (still) have coroutine scheduling bugs:
    they're calling functions from the wrong coroutine.  The utilities
    in tripemon would be useful, but they're tied to the glib event
    loop.

So here's the proposed fix.

  * SelCommandDispatcher is a mistake.  Split its functionality out into
    a separate class which can be plugged into TripeConnection or one of
    its descendants, so that clients which want a glib-based dispatcher
    can replace it without having to overturn the class hierarchy.

  * Move the scheduling utilities (`idly', `aside') from tripemon into
    tripe.py.  Make them available from services by providing a main
    loop in TripeConnection.

A few more wrinkles.

  * `idly' is renamed `defer' because that's what it does now: rather
    than waiting until there are no events incoming, it clears the decks
    of all deferred operations before looking for more events.

  * The interface of `spawn' has changed.  You provide a function to
    call in a new coroutine rather than a freshly minted coroutine that
    needs hacking.  All uses of `spawn' fit this pattern, so it's not a
    big deal, but it's worth mentioning.
mon/tripemon.in
py/tripe.py.in
svc/watch.in