[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] callback from event loop in wxPython

From: Karsten Hilbert
Subject: Re: [Gnumed-devel] callback from event loop in wxPython
Date: Fri, 30 Jan 2004 14:42:05 +0100
User-agent: Mutt/

> I have researched this issue in the past.
Excellent :-)

> It is very difficult to make
> wx apps listen to an arbitrary file descriptor, however, they can respond to 
> sockets
> generated within the libray (wxSocket class) with normal events.
hm, doesn't feel well technically

>> XML-RPC server
> Problem is, the XML-RPC server in the Python libraries does not use a 
> wxSocket, it uses a 
> 'plain' socket, a similar problem exists trying to listen for traffic on 
> postgres connections.
what exactly do you mean here ?

> A blocking background thread which invokes an event in the main thread may be 
> the best solution. 
Yes. And how does one do that ? :-) Is wxPython thread-safe so
PostEvent() (or whatever it's called) can be invoked from
within that listener thread ?

aah, wait, it appears to dawn on me ...

- start a thread that checks a given inbound stream
- if inbound data is found use gmDispatcher to emit a signal
  to that effect (that's empirically proven to work by the DB
  change listeners)
- one inbound-data-avail gmDispatcher-connected listener in
  the main thread receives such events and issues a
  wxCallAfter(gmScriptingProxy.process_next()) which gets us
  out of the quagmire

Hehe, off to trying this... :-)

duh, and the listener to inbound-data-avail
signals is gmScriptingProxy itself, of course (still using
wxCallAfter() since we can't be sure we won't be touching wx*
components inside the macro which isn't thread safe ...)

Whatever mechanism to ascertain inbound data availability is
plugged into the outside-listener thread doesn't matter, of

GPG key ID E4071346 @
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

reply via email to

[Prev in Thread] Current Thread [Next in Thread]