File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,22 @@ def process_handler(
97
97
sys .stderr .flush ()
98
98
out = None
99
99
finally :
100
+ # p.stdin / p.stderr / p.stdin are not the values passes to Pope, They
101
+ # are proxy reader/writer, and this is usually close in the context
102
+ # manager, but the __exit__ does self.wait(), and we can't
103
+ # afford this (see comment below),
104
+ # so we copy the first part of the exit routine.
105
+ #
106
+ if p .stdout :
107
+ p .stdout .close ()
108
+ if p .stderr :
109
+ p .stderr .close ()
110
+ try : # Flushing a BufferedWriter may raise an error
111
+ if p .stdin :
112
+ p .stdin .close ()
113
+ except (Exception , KeyboardInterrupt ):
114
+ print ("Error closing Stdin" )
115
+
100
116
# Make really sure that we don't leave processes behind, in case the
101
117
# call above raises an exception
102
118
# We start by assuming the subprocess finished (to avoid NameErrors
2912
You can’t perform that action at this time.
0 commit comments