문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top