Re: How to get a raised exception from other thread

2005-10-22 Thread dcrespo
> One suggestion about the above: "description" is actually the exception > instance (the object), not just the description. Yes. In fact, it's a tuple. Maybe, I'll change it for just printing the second item of it. Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a raised exception from other thread

2005-10-21 Thread WalterHoward
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > > Nevermind. I found a better solution. I used shared memory to create > > a keep-alive flag. I then use the select function with a specified > > timeout, and recheck the keep-alive flag after each timeout. > > As Dennis points out, your original

Re: How to get a raised exception from other thread

2005-10-21 Thread Peter Hansen
dcrespo wrote: > Ok, sorry about the above question. I solved it adding this to the main > thread: > > try: > SrvrTCP = module.ThreadedTCPServer(ip,port) > SrvrTCP.start() > except Exception, description: > MsgBox(self,"TCPServer > Error:\n\n"+str(description),title="TCPServer",style=w

Re: How to get a raised exception from other thread

2005-10-19 Thread dcrespo
Ok, sorry about the above question. I solved it adding this to the main thread: try: SrvrTCP = module.ThreadedTCPServer(ip,port) SrvrTCP.start() except Exception, description: MsgBox(self,"TCPServer Error:\n\n"+str(description),title="TCPServer",style=wx.OK | wx.ICON_ERROR) return

Re: How to get a raised exception from other thread

2005-10-19 Thread dcrespo
> Now that may not be perfect, since I'm not familiar with the TCPServer() > call. I've sort of assumed it does something quickly and returns, or > raises an exception if the input is bad. If it doesn't actually return > if it starts successfully, you would need a little different approach. > Pro

Re: How to get a raised exception from other thread

2005-10-19 Thread Antoon Pardon
Op 2005-10-18, dcrespo schreef <[EMAIL PROTECTED]>: >> Before, after, or during the .start() call, or somewhere else? > > I'd like to catch *just after* the .start() call. > >> I'm quite sure the problem you are trying to solve can be solved, but >> you are still describing part of the solution you

Re: How to get a raised exception from other thread

2005-10-18 Thread Peter Hansen
dcrespo wrote: >>Before, after, or during the .start() call, or somewhere else? > I'd like to catch *just after* the .start() call. Excellent. That makes it pretty easy then, since even though you are spawning a thread to do the work, your main thread isn't expected to continue processing in pa

Re: How to get a raised exception from other thread

2005-10-18 Thread dcrespo
> Before, after, or during the .start() call, or somewhere else? I'd like to catch *just after* the .start() call. > I'm quite sure the problem you are trying to solve can be solved, but > you are still describing part of the solution you believe you need, > rather than explaining why you want to

Re: How to get a raised exception from other thread

2005-10-17 Thread Peter Hansen
dcrespo wrote: >>Define what "get" means for your purposes. It appears that you mean you >>want to catch the exception, but in the thread which launched the other >>thread in the first place. If that's true, please show where you would >>expect to catch this exception, given that when you start t

Re: How to get a raised exception from other thread

2005-10-17 Thread dcrespo
Hi Peter. Sorry for my delay. I wasn't in home the weekend. > Define what "get" means for your purposes. It appears that you mean you > want to catch the exception, but in the thread which launched the other > thread in the first place. If that's true, please show where you would > expect to cat

Re: How to get a raised exception from other thread

2005-10-17 Thread Lasse Vågsæther Karlsen
Steve Holden wrote: >> Why should the coder of this software have to go through this >> deliberate set up attrition, to get at this functionality, just >> because it wasn't intented to be used in such a way by the >> developers? >> > Because otherwise people who know no better will use the feature

Re: How to get a raised exception from other thread

2005-10-17 Thread Antoon Pardon
Op 2005-10-17, Steve Holden schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2005-10-17, Alex Martelli schreef <[EMAIL PROTECTED]>: >> >>><[EMAIL PROTECTED]> wrote: >>> >>> Nevermind. I found a better solution. I used shared memory to create a keep-alive flag. I then use the se

Re: How to get a raised exception from other thread

2005-10-17 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Otherwise you have to write the worker thread to be capable of > handling asynchronous signals, which is a notoriously difficult task. Doing it properly needs a language extension. http://www.cs.williams.edu/~freund/papers/02-lwl2.ps -- http://mail.pyth

Re: How to get a raised exception from other thread

2005-10-17 Thread Steve Holden
Antoon Pardon wrote: > Op 2005-10-17, Alex Martelli schreef <[EMAIL PROTECTED]>: > >><[EMAIL PROTECTED]> wrote: >> >> >>>Nevermind. I found a better solution. I used shared memory to create >>>a keep-alive flag. I then use the select function with a specified >>>timeout, and recheck the keep-al

Re: How to get a raised exception from other thread

2005-10-17 Thread Antoon Pardon
Op 2005-10-17, Alex Martelli schreef <[EMAIL PROTECTED]>: ><[EMAIL PROTECTED]> wrote: > >> Nevermind. I found a better solution. I used shared memory to create >> a keep-alive flag. I then use the select function with a specified >> timeout, and recheck the keep-alive flag after each timeout. >

Re: How to get a raised exception from other thread

2005-10-17 Thread Antoon Pardon
Op 2005-10-14, dcrespo schreef <[EMAIL PROTECTED]>: > Hi all, > > How can I get a raised exception from other thread that is in an > imported module? > > For example: You could try the following class, it needs ctypes and if the exception is raised while in a C-extention, the exception will be del

Re: How to get a raised exception from other thread

2005-10-17 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Nevermind. I found a better solution. I used shared memory to create > a keep-alive flag. I then use the select function with a specified > timeout, and recheck the keep-alive flag after each timeout. Definitely a better architecture. Anyway, one supported way for

Re: How to get a raised exception from other thread

2005-10-16 Thread Lasse Vågsæther Karlsen
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > >> Nevermind. I found a better solution. I used shared memory to create >> a keep-alive flag. I then use the select function with a specified >> timeout, and recheck the keep-alive flag after each timeout. > > > As Dennis points out, your origi

Re: How to get a raised exception from other thread

2005-10-16 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Nevermind. I found a better solution. I used shared memory to create > a keep-alive flag. I then use the select function with a specified > timeout, and recheck the keep-alive flag after each timeout. As Dennis points out, your original attempt was destined to fail be

Re: How to get a raised exception from other thread

2005-10-16 Thread Klaas
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Nevermind. I found a better solution. I used shared memory to create > a keep-alive flag. I then use the select function with a specified > timeout, and recheck the keep-alive flag after each timeout. > > Thanx for all the input. How

Re: How to get a raised exception from other thread

2005-10-15 Thread themightydoyle
Nevermind. I found a better solution. I used shared memory to create a keep-alive flag. I then use the select function with a specified timeout, and recheck the keep-alive flag after each timeout. Thanx for all the input. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a raised exception from other thread

2005-10-15 Thread themightydoyle
Here's a dumbed down version of what i'm doing: import time import threading class threader(threading.Thread): def __init__(self): threading.Thread.__init__(self) pass def run(self): try: while 1: time.sleep(5) except SystemExit

Re: How to get a raised exception from other thread

2005-10-15 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I also need an answer to this problem. What _is_ the problem? We're still waiting for a clear description from the OP as to what the problem really is. How would you describe what _your_ problem is? > I'm using windows. Throwing an > exception in thread B from t

Re: How to get a raised exception from other thread

2005-10-15 Thread themightydoyle
I also need an answer to this problem. I'm using windows. Throwing an exception in thread B from thread A using a callback function. The function runs, but the thread never actually catches the exception. The try/except block is in the run() method (over-riden from the Thread class) -- http:/

Re: How to get a raised exception from other thread

2005-10-15 Thread Peter Hansen
dcrespo wrote: > How can I get a raised exception from other thread that is in an > imported module? Define what "get" means for your purposes. It appears that you mean you want to catch the exception, but in the thread which launched the other thread in the first place. If that's true, please

Re: How to get a raised exception from other thread

2005-10-15 Thread dcrespo
Thanks for your answer, but I think that created thread in python should create a thread either on windows and linux. Can you give me Python example of how to do what I want to do? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a raised exception from other thread

2005-10-14 Thread Shitiz Bansal
Threads can share the same memory space. Hence a very neat way to achieve the objective.   > For example:> > ---> programA.py> ---> > import programB Exception=0; > thread = programB.MakeThread()> thread.start() if (Exception):   raise SomeException() > ---

Re: How to get a raised exception from other thread

2005-10-14 Thread Jeremy Moles
On non-Windows system there are a ton of ways to do it--this is almost a whole field unto itself. :) (D-BUS, fifos, sockets, shmfs, etc.) In Windows, I wouldn't have a clue. I guess this is a hard question to answer without a bit more information. :) On Fri, 2005-10-14 at 14:45 -0700, dcrespo wr

How to get a raised exception from other thread

2005-10-14 Thread dcrespo
Hi all, How can I get a raised exception from other thread that is in an imported module? For example: --- programA.py --- import programB thread = programB.MakeThread() thread.start() --- programB.py --- import threading, time class SomeExcept