def test_exc_raised(self):
        class A1:
            @rpc()
            def mopo(self):
                raise ValueError()

        class A2:
            @regular()
            def reg(self) -> float:
                s = service(A1, url_a)
                s.mopo()
                return 2.

        act1 = A1()
        act2 = A2()
        el = EventLoop()
        sr = SignalRunner(el)

        url_a = 'udp://127.0.0.1:23456'

        actor_create(el, sr, A1, act1, [url_a])
        actor_create(el, sr, A2, act1, {DEFAULT_GROUP: 'udp://127.0.0.1'})

        try:
            el.loop()
        except ValueError:
            self.assertEqual('1', '1')
        except EventLoopEmpty:
            self.assertEqual('1', '0')
Exemple #2
0
def run_server(cls,
               cls_inst,
               bind_urls: Dict[str, str],
               horizon_each=60.,
               actor_name=None):
    el = EventLoop()
    sr = SignalRunner(el)

    if actor_name is None:
        if hasattr(cls, '__name__'):
            actor_name = cls.__name__
        else:
            actor_name = str(cls)

    act = actor_create(el,
                       sr,
                       cls,
                       cls_inst,
                       bind_urls,
                       horizon_each,
                       name=actor_name)

    try:
        el.loop()
    except EventLoopEmpty:
        pass
    except:
        act.terminate('exit')
        raise