On 03/07/2012 08:37 AM, Peng Xiao -X (penxiao - Digital China at Cisco) wrote:
> Because the function of parseBuffer is a litter time consuming, so the > receive buffer is full sometimes. The answer is: don't do that. If parseBuffer is expensive, you will block the reactor, which you must not do. You have two options: 1. Run the work in a thread with "deferToThread". Note: you MUST NOT call any reactor APIs from the thread, except reactor.callFromThread 2. Break the work up into small pieces, and run it incrementally. See twisted.internet.task.coiterate for example; this allows you to run any iterator, such as a generator, and get the result as a deferred. _______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
