From c87976af40b08f5ba030068d070a77ce66728ce0 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Wed, 20 Apr 2022 14:11:56 +0100 Subject: [PATCH] tests: Fix lingering Python 2 isms --- tests/bench/fork.py | 8 +++++++- tests/create_child_test.py | 2 +- tests/soak/cpu_load.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/bench/fork.py b/tests/bench/fork.py index af5cb3a7..d77f4437 100644 --- a/tests/bench/fork.py +++ b/tests/bench/fork.py @@ -5,6 +5,12 @@ Measure latency of .fork() setup/teardown. import mitogen import mitogen.core +try: + xrange +except NameError: + xrange = range + + @mitogen.main() def main(router): t0 = mitogen.core.now() @@ -12,4 +18,4 @@ def main(router): t = mitogen.core.now() ctx = router.fork() ctx.shutdown(wait=True) - print '++', 1000 * ((mitogen.core.now() - t0) / (1.0+x)) + print('++ %d' % 1000 * ((mitogen.core.now() - t0) / (1.0+x))) diff --git a/tests/create_child_test.py b/tests/create_child_test.py index 331c0171..aae5882d 100644 --- a/tests/create_child_test.py +++ b/tests/create_child_test.py @@ -79,7 +79,7 @@ def close_proc(proc): proc.stdin.close() proc.stdout.close() if proc.stderr: - prco.stderr.close() + proc.stderr.close() def wait_read(fp, n): diff --git a/tests/soak/cpu_load.py b/tests/soak/cpu_load.py index 8890272c..5a86fd0e 100644 --- a/tests/soak/cpu_load.py +++ b/tests/soak/cpu_load.py @@ -25,7 +25,7 @@ def burn(): mul = 1.5 count = int(mul * multiprocessing.cpu_count()) -print count +print(count) procs = [multiprocessing.Process(target=burn) for _ in range(count)]