[Twisted-Python] wxpython issues

Uwe C. Schroeder uwe at oss4u.com
Wed Apr 13 23:26:46 EDT 2005


You probably better switch to using separate threads.
Although I basically invented the timer driven "eventloop starving" quite a 
while ago, published it in the python cookbook (which eventually was turned 
into wxreactor by Itamar), I meanwhile switched my application to multiple 
threads. Works way better, particularly on windows.
The timer-eventloop works fine for smaller applications with little to 
moderate network usage, the moment you start transferring more data over the 
network you basically starve both eventloops to death, because neither of the 
loops gets enough CPU attention to do the job properly.

You might want to check out this example:

 http://solipsis.netofpeers.net/wiki/wikka.php?wakka=WxTwistedExample

It's a basic example of multiple threads, but it will give you the idea. 
I've written a network wrapper layer to make this whole thing more easy to 
handle, but I can't put this online just yet (contract reasons) - and it's 
very specialized for my application anyways.  Just to give you a hint: once 
you understood how the above example works, you can write wrapper classes for 
the remote referenceable interfaces of twisted. This allows you to use the 
twisted interface the way it's documented without having to fiddle around 
with the threads.

Hope that gives you some clues

UC



On Wednesday 13 April 2005 19:58, Anthony Baxter wrote:
> The problem has been that wx's timer promises "no worse
> than 1s" resolution. In practice, it's been utterly unable to
> hit less than 100ms on Windows, and 20ms on Linux is a
> sometimes-thing. The only real solution that works robustly
> is to run wx and twisted in separate threads. If there's a new
> version of wx, you should probably try running wxreactor with
> a LoopingCall set to 1ms, and see what timer it can hit
> reliably.
>
> Anthony

--
Open Source Solutions 4U, LLC	2570 Fleetwood Drive
Phone:  +1 650 872 2425		San Bruno, CA 94066
Cell:   +1 650 302 2405		United States
Fax:    +1 650 872 2417




More information about the Twisted-Python mailing list