diff --git a/crossbar/router/dealer.py b/crossbar/router/dealer.py index 587d21ca8..a4adb81cb 100644 --- a/crossbar/router/dealer.py +++ b/crossbar/router/dealer.py @@ -214,7 +214,7 @@ def detach(self, session): if invoke.timeout_call: invoke.timeout_call.cancel() invoke.timeout_call = None - + invokes = self._callee_to_invocations[callee] invokes.remove(invoke) if not invokes: diff --git a/crossbar/router/session.py b/crossbar/router/session.py index 964fe7da2..52267f646 100644 --- a/crossbar/router/session.py +++ b/crossbar/router/session.py @@ -736,12 +736,13 @@ def onClose(self, wasClean): self.onLeave(CloseDetails()) except Exception: self.log.failure("Exception raised in onLeave callback") + self.log.warn("{tb}".format(tb=Failure().getTraceback())) try: self._router.detach(self) except Exception as e: self.log.error("Failed to detach session '{}': {}".format(self._session_id, e)) - self.log.debug("{tb}".format(tb=Failure().getTraceback())) + self.log.warn("{tb}".format(tb=Failure().getTraceback())) self._session_id = None diff --git a/crossbar/router/test/test_dealer.py b/crossbar/router/test/test_dealer.py index 0dafe76e5..df2a9f4c2 100644 --- a/crossbar/router/test/test_dealer.py +++ b/crossbar/router/test/test_dealer.py @@ -111,10 +111,17 @@ def test_outstanding_invoke_but_caller_gone(self): outstanding = mock.Mock() outstanding.call.request = 1 + # there was a bug where timeout calls were not getting cancelled + # mock has non-null timeout_call, so we need to set it to None + outstanding.timeout_call = None dealer = self.router._dealer dealer.attach(session) + # All four maps involved in invocation tracking must be updated atomically + dealer._caller_to_invocations[outstanding.caller] = [outstanding] dealer._callee_to_invocations[session] = [outstanding] + dealer._invocations[outstanding.id] = outstanding + dealer._invocations_by_call[(outstanding.caller_session_id, outstanding.call.request)] = outstanding # pretend we've disconnected already outstanding.caller._transport = None diff --git a/crossbar/worker/proxy.py b/crossbar/worker/proxy.py index 476ccd9f6..cd83edf2e 100644 --- a/crossbar/worker/proxy.py +++ b/crossbar/worker/proxy.py @@ -634,7 +634,7 @@ def _process_Hello(self, msg): authmethod=hlval(authmethod), hello_result=hello_result) - #check if client disconnected while we were yielding to authenticator + # check if client disconnected while we were yielding to authenticator if not self.transport: self.log.debug( '{func} proxy frontend disconnected while processing hello in authenticator:' @@ -661,11 +661,11 @@ def _process_Hello(self, msg): if not self.transport: # we have not yet established a backend session, only authenticator session was used self.log.debug('{func} proxy frontend disconnected while connecting backend session' - ': session_id={session_id}, session={session}, details="{details}"', - func=hltype(self._process_Hello), - session_id=hlid(self._session_id), - session=self, - details=details) + ': session_id={session_id}, session={session}, details="{details}"', + func=hltype(self._process_Hello), + session_id=hlid(self._session_id), + session=self, + details=details) self._controller.unmap_backend(self, session) self._backend_session = None else: @@ -744,9 +744,9 @@ def _process_Authenticate(self, msg): # we have not yet established a backend session, only authenticator session was used self.log.info('{func} frontend disconnected while processing pending' ' authentication {pending_auth}: {authresult}', - func=hltype(self._process_Authenticate), - pending_auth=self._pending_auth, - authresult=auth_result) + func=hltype(self._process_Authenticate), + pending_auth=self._pending_auth, + authresult=auth_result) else: if isinstance(auth_result, types.Accept): try: @@ -1506,6 +1506,7 @@ def stop(self): topic = '{}.on_proxy_connection_stopped'.format(self._controller._uri_prefix) yield self._controller.publish(topic, self.marshal(), options=types.PublishOptions(acknowledge=True)) + class ProxyController(TransportController): """ Controller for proxy workers. Manages: @@ -1575,7 +1576,6 @@ def __init__(self, config=None, reactor=None, personality=None): # map: (realm_name, role_name) -> ProxyRoute self._service_sessions = {} - def has_realm(self, realm: str) -> bool: """ Check if a route to a realm with the given name is currently running. diff --git a/mypy.ini b/mypy.ini index d2ae62f24..f1020ef82 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,5 @@ [mypy] -python_version = 3.7 +python_version = 3.11 disable_error_code = annotation-unchecked [mypy-crossbar.worker.test.examples.*] diff --git a/requirements-dev.txt b/requirements-dev.txt index cc5bba177..4d1fc0c97 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -58,7 +58,7 @@ wheel twine hashin -pyinstaller==4.2 +pyinstaller>=4.2 # FIXME: the docker shit insists on old deps (yaml, jsonschema) # https://github.com/docker/compose/blob/30fcb72cf3b136598883752edfa6ea4f3b8643d4/setup.py#L27 diff --git a/requirements-latest.txt b/requirements-latest.txt index 266c92ec8..7ceb4cf7e 100644 --- a/requirements-latest.txt +++ b/requirements-latest.txt @@ -12,7 +12,7 @@ cookiecutter>=2.1.1 cryptography>=39.0.0 docker>=6.0.1 # required for python 3.11+ https://github.com/ethereum/eth-abi/pull/194 -eth-abi @ git+https://github.com/ethereum/eth-abi.git@v4.0.0-beta.2#egg=eth-abi +eth-abi==4.2.1 # required for python 3.11+ (https://github.com/ethereum/eth-account/pull/212) eth-account @ git+https://github.com/crossbario/eth-account.git@fix-215#egg=eth-account eth-typing @ git+https://github.com/ethereum/eth-typing.git@v3.2.0#egg=eth-typing diff --git a/tox.ini b/tox.ini index 2868b6490..5cb2c0042 100644 --- a/tox.ini +++ b/tox.ini @@ -162,7 +162,7 @@ exclude = crossbar/worker/test/examples/syntaxerror.py deps = bandit commands = - bandit -r -s B101,B110,B311 \ + bandit -r -s B101,B110,B311,B113 \ -x crossbar/common/key.py,crossbar/bridge/mqtt/test/test_wamp.py,crossbar/bridge/rest/test/__init__.py,crossbar/bridge/mqtt/test/test_wamp.py,crossbar/webservice/misc.py \ crossbar @@ -176,7 +176,7 @@ deps = commands = flake8 \ --exclude crossbar/shell/reflection \ - --ignore=E501,E402,E722,E741,W503,W504,E126,E251 \ + --ignore=E501,E402,E722,E741,W503,W504,E126,E251,E721 \ crossbar