From: Kevin A. <al...@se...> - 2004-09-24 06:51:08
|
On Sep 23, 2004, at 6:01 PM, Arthur Elsenaar wrote: > Hi, > > I'm trying to have multiple sockets updating progressbars and textual > status fields in a pythoncard window. I tried different approaches, > but am having very weird problems (yes, I'm rather new to python and > card). > > The most straight forward approach is to use asyncore as outlined > here: http://effbot.org/zone/effnews-1.htm > > I pass a reference to the async class, so it can find the widgets to > update. This works, but after a number of subsequent downloads, python > bails out with ugly errors like Bus error, segmentation fault.. also > rather strange visual anomalies occur; progressbars painted all over > the window, etc. nice, but not for this application. > > To me it looks like some memory corruption occurs, but how does this > happen? Circular references? Can I avoid these? > > Has anyone done something similar? I tried threads, but had exactly > the same problems, believing me that it has to do with how I try to > access the widgets from an instance of a class. When I use the > asyncore supposedly non blocking sockets, pythoncards GUI still > freezes up. Event loop problems? > > Hope my description rings a bell somewhere. > > Arthur > Without seeing the code, it is difficult to say, but are you using threads? If so, you can't access your GUI windows and components directly from the thread(s) handling the sockets. You need to use something that is thread-safe such as the Python Queue module. A couple of samples use threading and Queue and others avoid threads by using generators, but that probably wouldn't work for sockets. If you use something like Twisted then you don't need threads. There are other possible problems, but again it is a bit difficult to say without seeing some code. If you can zip it up and it isn't too big, then maybe you can send it to the list, otherwise, email me directly. You might also look at: http://wiki.wxpython.org/index.cgi/LongRunningTasks ka |