Skip to content

Use current_thread instead of currentThread that was deprecated in Python 3.10 #1145

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
Apr 17, 2021
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
8 changes: 4 additions & 4 deletions coverage/pytracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def log(self, marker, *args):
if 0:
f.write(".{:x}.{:x}".format(
self.thread.ident,
self.threading.currentThread().ident,
self.threading.current_thread().ident,
))
f.write(" {}".format(" ".join(map(str, args))))
if 0:
Expand Down Expand Up @@ -220,9 +220,9 @@ def start(self):
self.stopped = False
if self.threading:
if self.thread is None:
self.thread = self.threading.currentThread()
self.thread = self.threading.current_thread()
else:
if self.thread.ident != self.threading.currentThread().ident:
if self.thread.ident != self.threading.current_thread().ident:
# Re-starting from a different thread!? Don't set the trace
# function, but we are marked as running again, so maybe it
# will be ok?
Expand All @@ -243,7 +243,7 @@ def stop(self):
# right thread.
self.stopped = True

if self.threading and self.thread.ident != self.threading.currentThread().ident:
if self.threading and self.thread.ident != self.threading.current_thread().ident:
# Called on a different thread than started us: we can't unhook
# ourselves, but we've set the flag that we should stop, so we
# won't do any more tracing.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def test_coverage_stop_in_threads():
def run_thread(): # pragma: nested
"""Check that coverage is stopping properly in threads."""
deadline = time.time() + 5
ident = threading.currentThread().ident
ident = threading.current_thread().ident
if sys.gettrace() is not None:
has_started_coverage.append(ident)
while sys.gettrace() is not None:
Expand Down