From 56e83d5c4c853f1a1e7e7861ac6c81da0bdc582d Mon Sep 17 00:00:00 2001 From: shadeofblue Date: Tue, 27 Jun 2023 13:25:04 +0200 Subject: [PATCH] fix exception on network node removal --- yapapi/services/service_runner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yapapi/services/service_runner.py b/yapapi/services/service_runner.py index 461572c3c..b2b2abd13 100644 --- a/yapapi/services/service_runner.py +++ b/yapapi/services/service_runner.py @@ -6,6 +6,7 @@ from types import TracebackType from typing import TYPE_CHECKING, AsyncContextManager, List, Optional, Set, Tuple, Type, Union +import statemachine.exceptions from typing_extensions import Final if TYPE_CHECKING: @@ -414,7 +415,11 @@ async def _worker(work_context: WorkContext) -> None: raise finally: if network and service.network_node: - await network.remove_node(work_context.provider_id) + try: + await network.remove_node(work_context.provider_id) + except statemachine.exceptions.TransitionNotAllowed: + # no need to remove the node if the network is not there + pass service._clear_network_node() await self._job.engine.accept_payments_for_agreement(self._job.id, agreement.id) await self._job.agreements_pool.release_agreement(agreement.id, allow_reuse=False)