Re: Anyone Written a ReconnectingProxy Object?
Irmen de Jong <[email protected]>
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
On 30-6-2013 22:04, Kent Borg wrote: > So, I tried subclassng the Proxy object and writing a ReconnectingProxy > object, wrapping key methods with the try/except stuff to get them to > reconnect. I thought I had it working earlier today, but for some > reason my object isn't getting the exceptions. If I put them out in the > main code, I do get the exceptions, but not in my object. > > Anyone already done this? Catch the exception, reconnect, and (I guess) > try the original method call one more time. Users of the proxy just > treat it like an object that is more persistent than the regular Proxy > object... Have a look at the 'disconnects' example that comes with Pyro. The client code contains a AutoReconnectingProxy implementation (which uses the MSG_PING that was introduced in 4.20). Be aware that it is not very efficient: it requires two remote messages for every method call. So you trade efficiency for ease of use. Alternatively, posted earlier on this mailing list, here is one that should work with older versions of Pyro as well because it doesn't use MSG_PING: https://gist.github.com/irmen/5787860 It requires your Pyro object to have a 'ping' method though. Cheers Irmen ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev