How to use the txaio.is_called function in txaio

To help you get started, we’ve selected a few txaio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crossbario / txaio / test / test_is_future.py View on Github external
def test_is_called(framework):
    f = txaio.create_future_success(None)
    assert txaio.is_called(f)
github crossbario / autobahn-python / autobahn / wamp / component.py View on Github external
def on_disconnect(session, was_clean):
                    self.log.debug(
                        "session on_disconnect: was_clean={was_clean}",
                        was_clean=was_clean,
                    )
                    if not txaio.is_called(done):
                        if not was_clean:
                            self.log.warn(
                                u"Session disconnected uncleanly"
                            )
                        else:
                            # eg the session has left the realm, and the transport was properly
                            # shut down. successfully finish the connection
                            txaio.resolve(done, None)
                session.on('disconnect', on_disconnect)
github crossbario / autobahn-python / autobahn / wamp / protocol.py View on Github external
on_reply = self._subscribe_reqs.pop(msg.request).on_reply

                # ERROR reply to UNSUBSCRIBE
                elif msg.request_type == message.Unsubscribe.MESSAGE_TYPE and msg.request in self._unsubscribe_reqs:
                    on_reply = self._unsubscribe_reqs.pop(msg.request).on_reply

                # ERROR reply to REGISTER
                elif msg.request_type == message.Register.MESSAGE_TYPE and msg.request in self._register_reqs:
                    on_reply = self._register_reqs.pop(msg.request).on_reply

                # ERROR reply to UNREGISTER
                elif msg.request_type == message.Unregister.MESSAGE_TYPE and msg.request in self._unregister_reqs:
                    on_reply = self._unregister_reqs.pop(msg.request).on_reply

                if on_reply:
                    if not txaio.is_called(on_reply):
                        txaio.reject(on_reply, self._exception_from_message(msg))
                else:
                    raise ProtocolError("WampAppSession.onMessage(): ERROR received for non-pending request_type {0} and request ID {1}".format(msg.request_type, msg.request))

            else:

                raise ProtocolError("Unexpected message {0}".format(msg.__class__))
github crossbario / autobahn-python / autobahn / wamp / component.py View on Github external
def on_leave(session, details):
                    self.log.info(
                        "session leaving '{details.reason}'",
                        details=details,
                    )
                    if not txaio.is_called(done):
                        if details.reason in [u"wamp.close.normal"]:
                            txaio.resolve(done, None)
                        else:
                            f = txaio.create_failure(
                                ApplicationError(details.reason)
                            )
                            txaio.reject(done, f)
                session.on('leave', on_leave)
github crossbario / autobahn-python / autobahn / wamp / component.py View on Github external
def stop(self):
        self._stopping = True
        if self._session and self._session.is_attached():
            return self._session.leave()
        elif self._delay_f:
            # This cancel request will actually call the "error" callback of
            # the _delay_f future. Nothing to worry about.
            return txaio.as_future(txaio.cancel, self._delay_f)
        # if (for some reason -- should we log warning here to figure
        # out if this can evern happen?) we've not fired _done_f, we
        # do that now (causing our "main" to exit, and thus react() to
        # quit)
        if not txaio.is_called(self._done_f):
            txaio.resolve(self._done_f, None)
        return txaio.create_future_success(None)
github crossbario / autobahn-python / autobahn / wamp / protocol.py View on Github external
requests.clear()

        if outstanding:
            self.log.info(
                'Cancelling {count} outstanding requests',
                count=len(outstanding),
            )
        for request in outstanding:
            self.log.debug(
                'cleaning up outstanding {request_type} request {request_id}, '
                'firing errback on user handler {request_on_reply}',
                request_on_reply=request.on_reply,
                request_id=request.request_id,
                request_type=request.__class__.__name__,
            )
            if not txaio.is_called(request.on_reply):
                txaio.reject(request.on_reply, exc)

            # wait for any async-ness in the error handlers for on_reply
            txaio.add_callbacks(d, lambda _: request.on_reply, lambda _: request.on_reply)
        return d
github Kitware / VTK / ThirdParty / AutobahnPython / vtkAutobahn / autobahn / wamp / component.py View on Github external
def on_disconnect(session, was_clean):
                    self.log.debug(
                        "session on_disconnect: was_clean={was_clean}",
                        was_clean=was_clean,
                    )
                    if not txaio.is_called(done):
                        if was_clean:
                            # eg the session has left the realm, and the transport was properly
                            # shut down. successfully finish the connection
                            txaio.resolve(done, None)
                        else:
                            txaio.reject(done, RuntimeError('transport closed uncleanly'))
                session.on('disconnect', on_disconnect)
github crossbario / autobahn-python / autobahn / wamp / protocol.py View on Github external
requests.clear()

        if outstanding:
            self.log.info(
                'Cancelling {count} outstanding requests',
                count=len(outstanding),
            )
        for request in outstanding:
            self.log.debug(
                'cleaning up outstanding {request_type} request {request_id}, '
                'firing errback on user handler {request_on_reply}',
                request_on_reply=request.on_reply,
                request_id=request.request_id,
                request_type=request.__class__.__name__,
            )
            if not txaio.is_called(request.on_reply):
                txaio.reject(request.on_reply, exc)

            # wait for any async-ness in the error handlers for on_reply
            txaio.add_callbacks(d, lambda _: request.on_reply, lambda _: request.on_reply)
        return d
github crossbario / autobahn-python / autobahn / twisted / component.py View on Github external
def lost(fail):
                rtn = orig(fail)
                if not txaio.is_called(done):
                    txaio.reject(done, fail)
                return rtn
            proto.connectionLost = lost