summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2021-10-05 00:05:57 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2021-10-05 00:05:57 +0200
commit71e56f7141caa8cc451be23998d250c62b58f5a1 (patch)
treed904580fdf24330829ba691fea8b0d0721ca310d
parent46042187f58635598c8d7c7a771d131fc4e84ace (diff)
downloadpsutil-71e56f7141caa8cc451be23998d250c62b58f5a1.tar.gz
use ThreadTask as a ctx manager
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rwxr-xr-xpsutil/tests/test_linux.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index f5243c2c..23f6b221 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -1428,9 +1428,7 @@ class TestMisc(PsutilTestCase):
# - Process(tid) is supposed to work
# - pids() should not return the TID
# See: https://github.com/giampaolo/psutil/issues/687
- t = ThreadTask()
- t.start()
- try:
+ with ThreadTask():
p = psutil.Process()
threads = p.threads()
self.assertEqual(len(threads), 2)
@@ -1439,8 +1437,6 @@ class TestMisc(PsutilTestCase):
pt = psutil.Process(tid)
pt.as_dict()
self.assertNotIn(tid, psutil.pids())
- finally:
- t.stop()
def test_pid_exists_no_proc_status(self):
# Internally pid_exists relies on /proc/{pid}/status.