[Twisted-Python] Remote PB calls in ApplicationService.stopService
Alex Levy
mesozoic at polynode.com
Thu Jul 31 15:02:10 MDT 2003
I had two programs running; one was a twistd -y instance, the other was a
simple script that received objects over Perspective Broker and printed them
out.
The -y'able application consists of one Service:
class MyService(app.ApplicationService):
def somePBRemoteCall(self, event):
d = pb.getObjectAt(self.host, self.port, self.timeout)
d.addCallback(self.foundCatcher, event)
def foundCatcher(self, obj, event):
d = obj.callRemote('catch', event)
def stopService(self):
somePBRemoteCall(i_am_dying_event)
app.ApplicationService.stopService(self)
This isn't the code verbatim, but this is basically what it's doing. I want
the receiving side to be informed when the sending side is about to stop.
On the sending side, this results in 'Connection failed'. On the receiving
side, the following traceback appears. Could somebody more familiar with the
internals of Perspective Broker explain what's going wrong, or how I might
change my approach?
---snip---
Traceback (most recent call last):
File "sandbox/test-catcher.py", line 15, in ?
reactor.run()
File "/usr/lib/python2.2/site-packages/twisted/internet/default.py", line 122, in run
self.mainLoop()
File "/usr/lib/python2.2/site-packages/twisted/internet/default.py", line 133, in mainLoop
self.doIteration(t)
File "/usr/lib/python2.2/site-packages/twisted/internet/default.py", line 472, in doSelect
_logrun(selectable, _drdw, selectable, method, dict)
--- <exception caught here> ---
File "/usr/lib/python2.2/site-packages/twisted/python/log.py", line 65, in callWithLogger
callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.2/site-packages/twisted/python/log.py", line 52, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python2.2/site-packages/twisted/python/context.py", line 32, in callWithContext
return func(*args,**kw)
File "/usr/lib/python2.2/site-packages/twisted/internet/default.py", line 495, in _doReadOrWrite
selectable.connectionLost(f)
File "/usr/lib/python2.2/site-packages/twisted/internet/tcp.py", line 253, in connectionLost
protocol.connectionLost(reason)
File "/usr/lib/python2.2/site-packages/twisted/spread/pb.py", line 563, in connectionLost
for lobj in self.remotelyCachedObjects.values():
exceptions.AttributeError: Broker instance has no attribute 'remotelyCachedObjects'
---snip---
--
Alex Levy
WWW: http://mesozoic.geecs.org
"Never let your sense of morals prevent you from doing what is right."
-- Salvor Hardin, Isaac Asimov's _Foundation_
More information about the Twisted-Python
mailing list