def test_reject_pending(self): handler = ApplicationSession() MockTransport(handler) # This could happen if the task waiting on a request gets cancelled deferred = fail(Exception()) handler._call_reqs[1] = CallRequest(1, 'foo', deferred, {}) handler.onLeave(CloseDetails())
def call(self, procedure, *args, **kwargs): """ Implements :func:`autobahn.wamp.interfaces.ICaller.call` """ if six.PY2 and type(procedure) == str: procedure = six.u(procedure) assert (isinstance(procedure, six.text_type)) if not self._transport: raise exception.TransportLost() request_id = self._request_id_gen.next() if 'options' in kwargs and isinstance(kwargs['options'], types.CallOptions): options = kwargs.pop('options') msg = message.Call(request_id, procedure, args=args, kwargs=kwargs, **options.message_attr()) else: options = None msg = message.Call(request_id, procedure, args=args, kwargs=kwargs) # FIXME # def canceller(_d): # cancel_msg = message.Cancel(request) # self._transport.send(cancel_msg) # d = Deferred(canceller) on_reply = txaio.create_future() self._call_reqs[request_id] = CallRequest(request_id, on_reply, options) try: # Notes: # # * this might raise autobahn.wamp.exception.SerializationError # when the user payload cannot be serialized # * we have to setup a PublishRequest() in _publish_reqs _before_ # calling transpor.send(), because a mock- or side-by-side transport # will immediately lead on an incoming WAMP message in onMessage() # self._transport.send(msg) except: if request_id in self._call_reqs: del self._call_reqs[request_id] raise return on_reply