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()

Reply via email to