Skip to content

Fix for python-3.10 #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/ClusterShell/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def notify_all(self):
self._cond.acquire()
try:
self.suspend_count = min(self.suspend_count, 0)
self._cond.notifyAll()
self._cond.notify_all()
finally:
self._cond.release()

Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__(self, thread=None, defaults=None):
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
Expand Down Expand Up @@ -783,7 +783,7 @@ def _resume_thread(self):

def _resume(self):
"""Resume task - called from self thread."""
assert self.thread == threading.currentThread()
assert self.thread == threading.current_thread()
try:
try:
self._reset()
Expand All @@ -798,7 +798,7 @@ def _resume(self):
# 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):
Expand Down Expand Up @@ -972,14 +972,14 @@ def _terminate(self, kill):
# 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()

Expand Down Expand Up @@ -1394,7 +1394,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():
"""
Expand All @@ -1403,7 +1403,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():
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/TaskPortTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def ev_port_start(self, port):
def ev_msg(self, port, msg):
# receive msg
assert msg == "toto"
assert task_self().thread == threading.currentThread()
assert task_self().thread == threading.current_thread()
TaskPortTest.got_msg = True
task_self().abort()

Expand Down