How to kill a thread?
Hi there, How can I kill a threading.Thread subclass from MainThread? My threads are waiting for data in Queue.get() method: class MyThread(threading.Thread): def run(self): while True: data = queue.get()# <- here it waits most of the time ... process data >From the main thread I start several working threads: thr = MyThread() thr.start() ... feed the queue and at the end for each thread I'd like to do something like thr.kill() or thr.stop() or thr.destroy() or ... you got the point. I can't figure out how. Is there a way to do it? Thanks! JD -- http://mail.python.org/mailman/listinfo/python-list
Re: How to kill a thread?
On Fri, Jun 6, 2008 at 10:30 PM, John Dohn <[EMAIL PROTECTED]> wrote: > Hi there, > > How can I kill a threading.Thread subclass from MainThread? At the end I did: def run(self): while True: if exit_event.isSet(): # Thread exiting return try: data = q_in.get(timeout = .5) except Queue.Empty: continue # ... process data And then in the MainThread I do exit_event.set() and wait for all threads to exit. It's a pretty awkward solution but works. BTW Guys, is something like Thread.kill() planned for the future? Or is there a reason not to have it? Thanks JD -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CGI Upload from Server Status
On Sat, Jun 7, 2008 at 12:50 AM, Derek Tracy <[EMAIL PROTECTED]> wrote:
> I am trying to create a simple python cgi app that allows the user to kick
> off an ftp from the server the cgi is on to another server; I have that
> piece working using ftplib but since the files in question are usually very
> large (500mb to 2gb) in size I want to be able to display some sort of
> status to the user, preferrably a progress bar of some sort.
You'll need some AJAX progress bar (hint: google for this term ;-) that will
be getting updates from the server or request an update every second or so.
The question is if your upload code can provide progress tracking? If it's
just a call to some xyz.upload("/here/is/my-500M-file.bin") that only
returns after several minutes of uploading without giving you any updates on
how fast things go you're probably out of luck.
OTOH if it can do e.g.callbacks for progress reporting or if it can run in a
separate thread that you could query somehow you can hook that to that AJAX
thing of your choice.
JDJ
--
http://mail.python.org/mailman/listinfo/python-list
