how to make python socket server work with the app.MainLoop() in wxpython?

bryanjugglercryptographer at yahoo.com bryanjugglercryptographer at yahoo.com
Sun Jul 30 12:48:46 EDT 2006


Philippe Martin wrote:
> Philippe Martin wrote:
> > You need to have you server in a separate thread.
> PS:
>
> http://wiki.wxpython.org/index.cgi/LongRunningTasks


And here's an important bit from the wxWindows doc:

  For communication between secondary threads and the main thread,
  you may use wxEvtHandler::AddPendingEvent or its short version
  wxPostEvent. These functions have thread safe implementation
  [...]
  <http://www.wxwindows.org/manuals/2.6.3/wx_wxthreadoverview.html>

Calling various wxWindows functions from threads other than the
one that runs the GUI, can cause a crash. Use only those that the
authoritative documentation states to be thread-safe, such as
wxPostEvent. The Wiki page that Pilippe cited says that
wxCallAfter uses wxPostEvent internally, so it should also be
thread-safe. I still wouldn't use it; internals are subject to
change.


-- 
--Bryan




More information about the Python-list mailing list