1

How can I handle Asyncore.dispatcher(s) and SimpleXMLRPCServer events from the same event-loop?

P.S. I already know that some of you might recommend Twisted for this, but the problem with Twisted is that it is a little bit too high-level library for my needs. In particular I am doing UDP flow-control by overriding Asyncore.dispatcher.writable() method that depends on timers. Not sure if/how this could be doable in Twisted.

user389238
  • 1,656
  • 3
  • 19
  • 40

1 Answers1

1

You should use Twisted for this :-). You can't put SimpleXMLRPCServer into an asynchronous loop; it's synchronous code, which expects to block.

Flow-control with Twisted, even with UDP, is easy. Rather than overriding a method like writable(), your DatagramProtocol can call methods like stopReading / stopWriting / startReading / startWriting on their transport attribute. You can see these methods here.

Glyph
  • 31,152
  • 11
  • 87
  • 129
  • SimpleXMLRPCServer uses asynchronous IO for reading, while writing is blocking. Anyway, while Twisted seems to be high-level library it is still possible to do all the same things as in low-level asyncore. I suppose I could inherit from Twisted's FileDescriptor to get the low level IO features or use Twisted Prodcuers. The latter option even seems better solution. Thanks. – user389238 Oct 27 '11 at 16:41