Skip to content

Commit

Permalink
Deprecate methods from threading module
Browse files Browse the repository at this point in the history
There are a few threading methods been deprecated since Python3.10,
let's replace them according to the guide.

Reference: https://docs.python.org/3/whatsnew/3.10.html#deprecated
Issue: avocado-framework#3837

Signed-off-by: Xu Han <[email protected]>
  • Loading branch information
luckyh committed Feb 1, 2024
1 parent 85258d3 commit e82b82c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion selftests/unit/test_utils_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _update_env(env, key, value):
key = "%s" % utils_misc.generate_random_string(length=10)
value = "%s" % utils_misc.generate_random_string(length=10)
_update_env(env, key, value)
if termination_event.isSet():
if termination_event.is_set():
break

changing_thread = threading.Thread(target=update_env,
Expand Down
4 changes: 2 additions & 2 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ def _take_screendumps(test, params, env):
os.unlink(temp_filename)

if _screendump_thread_termination_event is not None:
if _screendump_thread_termination_event.isSet():
if _screendump_thread_termination_event.is_set():
_screendump_thread_termination_event = None
break
_screendump_thread_termination_event.wait(delay)
Expand Down Expand Up @@ -2141,7 +2141,7 @@ def report_result(status, cmd, results):
cmd_details[cmd]['counter'][vm.instance] += 1

if _vm_info_thread_termination_event is not None:
if _vm_info_thread_termination_event.isSet():
if _vm_info_thread_termination_event.is_set():
_vm_info_thread_termination_event = None
for cmd in cmds:
report_result("Thread quit", cmd,
Expand Down
Loading

0 comments on commit e82b82c

Please sign in to comment.