Re: Pyro4 does not throw ConnectionClosedError
Irmen de Jong <[email protected]> Mon, 30 Mar 2015 23:25:20 +0200
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
Hello Dieter! On 29-3-2015 21:39, dieter-eJWuXbj/[email protected] wrote: > Hi, > > I'm running pyro 4.31 and use it on my amazon ec2 instances. I'm mainly running spot Have you tried it with the latest Pyro version? > price instances which means I often have to deal with a server that goes down. So I need > to be able to catch an exception when the my proxy object loses connection to the remote > object. > > So I have code similar to > > for ... > proxy = Pyro4.async(Pyro4.Proxy(pyro_uri)) > future_result[i].proxy.run() That code doesn't make much sense, what is future_result[i]? If we have to look at some code please post (parts of) the actual code. > ... some other code > for .... > try: > future_result[i].wait() > except ConnectionClosedError:.... > At some point this worked and a ConnectionClosedError was thrown in case the connection > was lost, but now it just keeps hanging on the wait command even if the server is down. Please define "at some point this worked" and "but now it hangs". What did you change in between? > I looked in de Pyro4 code and I must say I don't see how a loss of connection can > unblock the wait command as the wait command waits until the Event boolean is set to > True which is quite impossible to do when the server is down. What makes you reach this conclusion, because in the __asynccall method of the _AsyncRemoteMethod class (which wraps the remote method call in case of an async proxy) there's an exception handler that sets the value property of the FutureResult object. That setter also sets the event boolean to true. > So how can I best detect > when connection is lost? If the server is still up, but I shutdown the pyro daemon then > a connection closed error is thrown, but I want it when the entire server goes down. I'm not following you here sorry, can you rephrase this please? > EDIT: it seems that python's recv function does not throw an error which might be the > underlying cause why no error is thrown in Pryo4 either? That's strange. The recv function is a simple wrapper around a plain socket.recv() so I'm not sure what is going on. If the recv() doesn't return, well, Pyro won't either, and so there won't be any error condition to report. What are you doing that makes the recv() hang? Are you sure it sits in the recv()? Perhaps your system has an abnormally big socket timeout value? What happens when you specify a Pyro timeout in your own config? Irmen ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/