Skip to content

Commit fe01584

Browse files
committed
FIX undefined local
1 parent 8579372 commit fe01584

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/test_resource_tracker.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ def test_child_retrieves_resource_tracker(self):
4444
# First simple fd retrieval check (see #200)
4545
# checking fd only work on posix for now
4646
if sys.platform != "win32":
47-
parent_rtracker_fd = get_rtracker_fd()
48-
executor = ProcessPoolExecutor(max_workers=2)
49-
child_rtracker_fd = executor.submit(get_rtracker_fd).result()
47+
try:
48+
parent_rtracker_fd = get_rtracker_fd()
49+
executor = ProcessPoolExecutor(max_workers=2)
50+
child_rtracker_fd = executor.submit(get_rtracker_fd).result()
5051

51-
assert child_rtracker_fd == parent_rtracker_fd
52+
assert child_rtracker_fd == parent_rtracker_fd
53+
finally:
54+
executor.shutdown()
5255

5356
# Register a resource in the parent process, and un-register it in the
5457
# child process. If the two processes do not share the same
@@ -80,23 +83,20 @@ def maybe_unlink(name, rtype):
8083
e.submit(maybe_unlink, filename, "file").result()
8184
e.shutdown()
8285
"""
83-
try:
84-
p = subprocess.run(
85-
[sys.executable, "-E", "-c", cmd],
86-
capture_output=True,
87-
text=True,
88-
)
89-
filename = p.stdout.strip()
9086

91-
pattern = f"decremented refcount of file {filename}"
92-
assert pattern in p.stderr
93-
assert "leaked" not in p.stderr
87+
p = subprocess.run(
88+
[sys.executable, "-E", "-c", cmd],
89+
capture_output=True,
90+
text=True,
91+
)
92+
filename = p.stdout.strip()
9493

95-
pattern = f"KeyError: '{filename}'"
96-
assert pattern not in p.stderr
94+
pattern = f"decremented refcount of file {filename}"
95+
assert pattern in p.stderr
96+
assert "leaked" not in p.stderr
9797

98-
finally:
99-
executor.shutdown()
98+
pattern = f"KeyError: '{filename}'"
99+
assert pattern not in p.stderr
100100

101101
# The following four tests are inspired from cpython _test_multiprocessing
102102
@pytest.mark.parametrize("rtype", ["file", "folder", "semlock"])

0 commit comments

Comments
 (0)