Roundoup
unread,May 7, 2010, 5:43:54 PM5/7/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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()