Re: Anyone Written a ReconnectingProxy Object?
Kent Borg <[email protected]>
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
On 06/30/2013 06:10 PM, Irmen de Jong wrote:
> 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.
Finally got a chance to look at this (day job and all...), and I like
it. (Looks like I was subclassing the slightly wrong object and I didn't
know about _pyroInvoke, a very nice bottleneck for this.)
But I have another question: Instead of the "try" doing a ping method,
why not use the actual desired method instead of the ping--if it works
we charge on with our work, and only if we get the "except" do we
reconnect and attempt the same desired method again?
For example, based on some quick testing, this seems to work:
class ReconnectingProxy(Pyro4.core.Proxy):
def _pyroInvoke(self, methodname, vargs, kwargs, flags=0):
try:
return super(ReconnectingProxy,
self)._pyroInvoke(methodname, vargs, kwargs, flags)
except Pyro4.errors.ConnectionClosedError:
self._pyroReconnect()
return super(ReconnectingProxy,
self)._pyroInvoke(methodname, vargs, kwargs, flags)
I seems in the normal case this would run at full speed by not having a
ping. Am I missing something?
Thanks,
-kb
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev