Skip to content

Commit d765491

Browse files
committed
Use try/finally instead of a nested handler
1 parent de43735 commit d765491

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

Lib/asyncio/unix_events.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -876,18 +876,17 @@ def _do_wait(self, pid, pidfd, callback, args):
876876
loop = events.get_running_loop()
877877
loop._remove_reader(pidfd)
878878
try:
879-
try:
880-
_, status = os.waitpid(pid, 0)
881-
except ChildProcessError:
882-
# The child process is already reaped
883-
# (may happen if waitpid() is called elsewhere).
884-
returncode = 255
885-
logger.warning(
886-
"child process pid %d exit status already read: "
887-
" will report returncode 255",
888-
pid)
889-
else:
890-
returncode = waitstatus_to_exitcode(status)
879+
_, status = os.waitpid(pid, 0)
880+
except ChildProcessError:
881+
# The child process is already reaped
882+
# (may happen if waitpid() is called elsewhere).
883+
returncode = 255
884+
logger.warning(
885+
"child process pid %d exit status already read: "
886+
" will report returncode 255",
887+
pid)
888+
else:
889+
returncode = waitstatus_to_exitcode(status)
891890
finally:
892891
os.close(pidfd)
893892
callback(pid, returncode, *args)

0 commit comments

Comments
 (0)