diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-16 20:23:29 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-16 20:23:29 +0200 |
commit | e0ff6ee99f624a1d11a2ab6b833867fb7898d975 (patch) | |
tree | 34f4c2ed9f3ab5d7fff96b1f1c5e7f81dc59518c | |
parent | be82ee662cd5a983c246a97c70a7da664c2bb567 (diff) | |
download | psutil-e0ff6ee99f624a1d11a2ab6b833867fb7898d975.tar.gz |
speed up multi socks tests by waiting for multiple test files in parallel
-rwxr-xr-x | psutil/tests/test_connections.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index 927d5bfb..00d94a6a 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -458,17 +458,25 @@ class TestSystemWideConnections(unittest.TestCase): with create_sockets() as socks: expected = len(socks) pids = [] - src = textwrap.dedent("""\ - import time - from psutil.tests import create_sockets - with create_sockets(): - open('%s', 'w').close() - time.sleep(60) - """ % TESTFN) - for x in range(10): + times = 10 + for i in range(times): + fname = TESTFN + str(i) + src = textwrap.dedent("""\ + import time, os + from psutil.tests import create_sockets + with create_sockets(): + with open('%s', 'w') as f: + f.write(str(os.getpid())) + time.sleep(60) + """ % fname) sproc = pyrun(src) - wait_for_file(TESTFN, empty=True) pids.append(sproc.pid) + self.addCleanup(safe_rmpath, fname) + + # sync + for i in range(times): + fname = TESTFN + str(i) + wait_for_file(fname) syscons = [x for x in psutil.net_connections(kind='all') if x.pid in pids] |