@@ -186,15 +186,6 @@ def get_validator_command():
186
186
# - Close remaining program + write end of pipe
187
187
# - Close remaining read end of pipes
188
188
189
- def set_pipe_size (pipe ):
190
- # Somehow, setting the pipe buffer size is necessary to avoid hanging in larger interactions.
191
- # Note that this is equivalent to Popen's `pipesize` argument in Python 3.10,
192
- # but we backported this for compatibility with older Python versions:
193
- # https://github.com/python/cpython/pull/21921/files#diff-619941af4b328b6abf2dc02c54e774fc17acc1ac4172c14db27d6097cbbff92aR1590
194
- # See also: https://github.com/RagnarGrootKoerkamp/BAPCtools/pull/251#issuecomment-1609353538
195
- # Note: 1031 = fcntl.F_SETPIPE_SZ, but that constant is also only available in Python 3.10.
196
- fcntl .fcntl (pipe , 1031 , BUFFER_SIZE )
197
-
198
189
interaction_file = None
199
190
# TODO: Print interaction when needed.
200
191
if interaction and interaction is not True :
@@ -231,6 +222,7 @@ def set_pipe_size(pipe):
231
222
# TODO: Make a flag to pass validator error directly to terminal.
232
223
stderr = subprocess .PIPE if validator_error is False else None ,
233
224
cwd = validator_dir ,
225
+ pipesize = BUFFER_SIZE ,
234
226
preexec_fn = limit_setter (validator_command , validator_timeout , None , 0 ),
235
227
)
236
228
validator_pid = validator .pid
@@ -240,17 +232,13 @@ def set_pipe_size(pipe):
240
232
241
233
assert validator .stdin and validator .stdout
242
234
243
- set_pipe_size (validator .stdin )
244
- set_pipe_size (validator .stdout )
245
- if validator_error is False :
246
- set_pipe_size (validator .stderr )
247
-
248
235
if interaction :
249
236
team_tee = subprocess .Popen (
250
237
['python3' , '-c' , TEE_CODE , '>' ],
251
238
stdin = subprocess .PIPE ,
252
239
stdout = validator .stdin ,
253
240
stderr = interaction_file ,
241
+ pipesize = BUFFER_SIZE ,
254
242
preexec_fn = limit_setter (None , None , None , gid ),
255
243
)
256
244
team_tee_pid = team_tee .pid
@@ -259,28 +247,24 @@ def set_pipe_size(pipe):
259
247
stdin = validator .stdout ,
260
248
stdout = subprocess .PIPE ,
261
249
stderr = interaction_file ,
250
+ pipesize = BUFFER_SIZE ,
262
251
preexec_fn = limit_setter (None , None , None , gid ),
263
252
)
264
253
val_tee_pid = val_tee .pid
265
254
266
- set_pipe_size (team_tee .stdin )
267
- set_pipe_size (val_tee .stdout )
268
-
269
255
submission = subprocess .Popen (
270
256
submission_command ,
271
257
stdin = (val_tee if interaction else validator ).stdout ,
272
258
stdout = (team_tee if interaction else validator ).stdin ,
273
259
stderr = subprocess .PIPE if team_error is False else None ,
274
260
cwd = submission_dir ,
261
+ pipesize = BUFFER_SIZE ,
275
262
preexec_fn = limit_setter (submission_command , timeout , memory_limit , gid ),
276
263
)
277
264
submission_pid = submission .pid
278
265
279
266
assert validator .stderr and submission .stderr
280
267
281
- if team_error is False :
282
- set_pipe_size (submission .stderr )
283
-
284
268
stop_kill_handler = threading .Event ()
285
269
submission_time : Optional [float ] = None
286
270
0 commit comments