Backported from upstream commit 314767d65c39 ("Fix for python-3.10") [1]. [1] https://github.com/cea-hpc/clustershell/commit/314767d65c397fadc5ce0ae205a35d7bb47a68a8 diff --git a/lib/ClusterShell/Task.py b/lib/ClusterShell/Task.py index b9142e6..8c9e1b9 100644 --- a/lib/ClusterShell/Task.py +++ b/lib/ClusterShell/Task.py @@ -254,7 +254,7 @@ class Task(object): self._cond.acquire() try: self.suspend_count = min(self.suspend_count, 0) - self._cond.notifyAll() + self._cond.notify_all() finally: self._cond.release() @@ -347,7 +347,7 @@ class Task(object): def _is_task_self(self): """Private method used by the library to check if the task is task_self(), but do not create any task_self() instance.""" - return self.thread == threading.currentThread() + return self.thread == threading.current_thread() def default_excepthook(self, exc_type, exc_value, tb): """Default excepthook for a newly Task. When an exception is @@ -765,7 +765,7 @@ class Task(object): def _resume(self): """Resume task - called from self thread.""" - assert self.thread == threading.currentThread() + assert self.thread == threading.current_thread() try: try: self._reset() @@ -780,7 +780,7 @@ class Task(object): # task becomes joinable self._join_cond.acquire() self._suspend_cond.atomic_inc() - self._join_cond.notifyAll() + self._join_cond.notify_all() self._join_cond.release() def resume(self, timeout=None): @@ -954,14 +954,14 @@ class Task(object): # termination (late join()s) # must be called after _terminated is set to True self._join_cond.acquire() - self._join_cond.notifyAll() + self._join_cond.notify_all() self._join_cond.release() # destroy task if needed if kill: Task._task_lock.acquire() try: - del Task._tasks[threading.currentThread()] + del Task._tasks[threading.current_thread()] finally: Task._task_lock.release() @@ -1376,7 +1376,7 @@ def task_self(defaults=None): provided as a convenience is available in the top-level ClusterShell.Task package namespace. """ - return Task(thread=threading.currentThread(), defaults=defaults) + return Task(thread=threading.current_thread(), defaults=defaults) def task_wait(): """ @@ -1385,7 +1385,7 @@ def task_wait(): convenience and is available in the top-level ClusterShell.Task package namespace. """ - Task.wait(threading.currentThread()) + Task.wait(threading.current_thread()) def task_terminate(): """ diff --git a/tests/TaskPortTest.py b/tests/TaskPortTest.py index 697f144..4014a89 100644 --- a/tests/TaskPortTest.py +++ b/tests/TaskPortTest.py @@ -28,7 +28,7 @@ class TaskPortTest(unittest.TestCase): def ev_msg(self, port, msg): # receive msg assert msg == "toto" - assert port.task.thread == threading.currentThread() + assert port.task.thread == threading.current_thread() TaskPortTest.got_msg = True port.task.abort() -- 2.35.1