If your task is fairly complex to get results from, it may be worth
looking at DelayedResult.py (posted Aug 17th), which makes it trivial to
build complex async result post-processing with wx. Simplistic example
(doesn't show the real power of DelayedResult -- chaining transformers):
import DelayedResult, thread
# this gets called when worker thread done:
def listener(delayedResult):
print delayedResult.get()
# create a channel to get result to 'listener'
channel, port = DelayedResult.byCall(listener)
# create the worker function; you don't have to use
# decorator if you don't want, it just eliminates
# some repetitive stuff:
@ DelayedResult.autoSend()
def workerFunc():
# do some stuff
import time
time.sleep(3)
return 'aResult'
# start the worker thread
sender = channel.getSender()
thread.start_new_thread( workerFunc, (sender,) )
Oliver
···
-----Original Message-----
From: Brendan Simon [mailto:Brendan@BrendanSimon.com]
Sent: August 24, 2006 4:12 AM
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Long actionsI'm writing a GUI frontend for a Configuration Management
System called Aegis. The GUI may have many tabs to view
information about multiple changesets on multiple branches,
etc. On requirement of Aegis is to perform a build. Builds
may take a long time depending on the project (eg. over an
hour). I was planning on using something like "popen("aegis
-build ...") to perform the builds and have the output text
displayed in a text area.Will this block my GUI from responding until popen finishes?
I want to be able to do multiple builds for different
changesets, as well as other functions such as adding new
changesets, etc.
If popen blocks, then I guess I would have to do something
like run the popen in a different thread. Is that the way to go?If threads are used, how do I detect new output from popen to
update each text area in "real time" ??Thanks for any help or pointers.
Brendan.---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org