ConnectionClosed and fire

0 views
Skip to first unread message

Roundoup

unread,
May 7, 2010, 5:43:54 PM5/7/10
to diesel users
Hi,

I have an application with Service and Loop. Service calls Loop by
'fire' and Loop reads it by 'wait'.
All works fine except calling it in case 'ConnectionClosed' (Loop does
not get a trigger)
In code below, it works for inp == 1 but not for inp ==0.
Does anyone know why?

Thanks,
Roundoup

from diesel import Application, Service, Loop, until_eol, wait, fire
from diesel.core import ConnectionClosed

class XYZService(Service):
def __init__(self, port=8888):
Service.__init__(self, self.main_loop, port)

def main_loop(self, addr):
while True:
try:
inp = yield until_eol()
yield fire('xxx',1)
except ConnectionClosed:
print "Connection closed"
yield fire('xxx',0)

def loop():
while True:
print "in"
inp = yield wait('xxx')
if inp == 1:
print "got msg"
elif inp == 0:
print "closed cxn"
print "out"

app = Application()
app.add_loop(Loop(loop))
app.add_service(XYZService())
app.run()

Eric Larson

unread,
May 10, 2010, 10:51:41 AM5/10/10
to diesel...@googlegroups.com
At Fri, 7 May 2010 14:43:54 -0700 (PDT),
I have actually seen a similar situation. In my case what happens is
when the loop "fires" an event for the service, it sends a signal to
its connected client, but then that connection seems to close.

Eric

Roundoup

unread,
May 11, 2010, 2:59:06 PM5/11/10
to diesel users
Problem was fixed:
http://bitbucket.org/boomplex/diesel/changeset/e855bf25042c

Thanks,
Roundoup
Reply all
Reply to author
Forward
0 new messages