Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top