diff --git a/examples/Transports/FIX/over_one_session.py b/examples/Transports/FIX/over_one_session.py index 289cf2929..8d00d3c5d 100644 --- a/examples/Transports/FIX/over_one_session.py +++ b/examples/Transports/FIX/over_one_session.py @@ -162,6 +162,7 @@ def get_multitest(): target="ISLD", msgclass=FixMessage, codec=CODEC, + logoff_at_stop=False, ), ], ) diff --git a/testplan/common/entity/base.py b/testplan/common/entity/base.py index 11d9bc813..3afab5030 100644 --- a/testplan/common/entity/base.py +++ b/testplan/common/entity/base.py @@ -474,7 +474,7 @@ def get_options(cls): ConfigOption("initial_context", default={}): dict, ConfigOption("path_cleanup", default=False): bool, ConfigOption("status_wait_timeout", default=600): int, - ConfigOption("abort_wait_timeout", default=30): int, + ConfigOption("abort_wait_timeout", default=300): int, ConfigOption("active_loop_sleep", default=0.005): float, } @@ -632,7 +632,15 @@ def _abort_entity(self, entity, wait_timeout=None): self.logger.error(traceback.format_exc()) self.logger.error("Exception on aborting %s - %s", entity, exc) else: - if wait(lambda: entity.aborted is True, timeout) is False: + + if ( + wait( + predicate=lambda: entity.aborted is True, + timeout=timeout, + raise_on_timeout=False, # continue even if some entity timeout + ) + is False + ): self.logger.error("Timeout on waiting to abort %s.", entity) def aborting(self): @@ -1133,9 +1141,16 @@ def run(self): while self._ihandler.active: time.sleep(self.cfg.active_loop_sleep) else: + # TODO: need some rework + # if we abort from ui, the ihandler.abort executes in http thread + # if we abort by ^C, ihandler.abort is called in main thread + # anyway this join will not be blocked interruptible_join( thread, timeout=self.cfg.abort_wait_timeout ) + # if we abort from ui, we abort ihandler first, then testrunner + # this abort will wait ihandler to be aborted + # if we abort by ^C, testrunner.abort is already called, this will be noop self.abort() return self._ihandler else: @@ -1693,6 +1708,7 @@ def _handle_abort(self, signum, frame): signum, threading.current_thread(), ) + self.abort() def pausing(self): diff --git a/testplan/runnable/base.py b/testplan/runnable/base.py index 90c1bba30..3cdf4a3b9 100644 --- a/testplan/runnable/base.py +++ b/testplan/runnable/base.py @@ -961,10 +961,12 @@ def _wait_ongoing(self): "Timeout: Aborting execution after %d seconds", self.cfg.timeout, ) - # Abort dependencies, wait sometime till test reports are ready + # Abort resources e.g pools for dep in self.abort_dependencies(): self._abort_entity(dep) - time.sleep(self.cfg.abort_wait_timeout) + # TODO: we shall not need this: + # # wait sometime till test reports are ready + # time.sleep(self.cfg.abort_wait_timeout) break pending_work = False diff --git a/testplan/runners/pools/tasks/base.py b/testplan/runners/pools/tasks/base.py index 9a8ed84be..2b488e586 100644 --- a/testplan/runners/pools/tasks/base.py +++ b/testplan/runners/pools/tasks/base.py @@ -114,13 +114,7 @@ def uid(self) -> str: @property def name(self) -> str: """Task name.""" - if not isinstance(self._target, str): - try: - name = self._target.__class__.__name__ - except AttributeError: - name = self._target - else: - name = self._target + name = self._uid or self._target return "Task[{}]".format(name) @property