[Tutor] Does Python have any callback function?

Alan Gauld alan.gauld at btinternet.com
Mon Jan 29 01:57:27 CET 2007


"Wong Vincent" <thian_seng at yahoo.com> wrote

> My current application has 2 python scripts running in parallel, say 
> script A and B.
> script A: GUI
> script B: data processing.

OK, Thats a slightly unusual way to do things unless the data
processing is acting as a server for multiple clients. Normally
we would write the data processing as a module that exposed
some functions (or classes) that are called from the GUI and
the GUI then updates the interface with the result.

But assuming you must use two separate scripts running as
two processes then you can still get them to interwork. Take
a look at my tutorial under the topic inter-process-communication
for how to use pipes. If it is a multi-client server (or iof the 
serrver
is on another machine from the GUI) then sockets may be more
appropriate (I haven't gotten round to finishing that topic yet! :-)

>  A will invoke B to run. If I would like B to update processing
> status to A

But since you say A invokles B I suspect pipes will be fine.
But equally rewriting B as a module will be even better.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list