diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-02 14:48:34 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-02 14:48:34 +0200 |
commit | a67ef14124eb30ee77be70aab92ff5ca3c7ff42a (patch) | |
tree | 7e8a1737dbe4edb5b13b50e9c54e621c9f08dbde | |
parent | 6b65dd172aeb885142253f498b042fab7f85abee (diff) | |
download | psutil-a67ef14124eb30ee77be70aab92ff5ca3c7ff42a.tar.gz |
refactor
-rw-r--r-- | psutil/tests/__init__.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 077eca22..3c1d9015 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -458,21 +458,6 @@ def sh(cmd, **kwds): return stdout -def _assert_no_pid(pid): - # This is here to make sure wait_procs() behaves properly and - # investigate: - # https://ci.appveyor.com/project/giampaolo/psutil/build/job/ - # jiq2cgd6stsbtn60 - assert not psutil.pid_exists(pid), pid - assert pid not in psutil.pids(), pid - try: - p = psutil.Process(pid) - except psutil.NoSuchProcess: - pass - else: - assert 0, "%s is still alive" % p - - def terminate(proc_or_pid, sig=signal.SIGTERM, wait_timeout=GLOBAL_TIMEOUT): """Terminate a process and wait() for it. Process can be a PID or an instance of psutil.Process(), @@ -550,7 +535,8 @@ def terminate(proc_or_pid, sig=signal.SIGTERM, wait_timeout=GLOBAL_TIMEOUT): finally: if isinstance(p, (subprocess.Popen, psutil.Popen)): flush_popen(p) - _assert_no_pid(p if isinstance(p, int) else p.pid) + pid = p if isinstance(p, int) else p.pid + assert not psutil.pid_exists(pid), pid def reap_children(recursive=False): |