Skip to content

Commit 6ec7510

Browse files
committed
Fixed some Judging executions fail to work.
Only occurs on programs with large input and scanf("%s").
1 parent 4169625 commit 6ec7510

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

pyjudge/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""
1616

1717
__configs = {
18-
# 'tmp_dir': 'C:/Users/Administrator/AppData/Temp/PyJudge/',
18+
# 'tmp_dir': 'C:/Users/Administrator/AppData/Local/Temp/PyJudgeTemp/',
1919
'tmp_dir': './PyJudgeTemp/',
2020
'max_output': 64*1024*1024, # 64 MB Maximum allowed output
2121
'table_max_lines': 20,

pyjudge/process.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ def execute(self):
7070
stderr=subprocess.PIPE)
7171
# Marking begin timestamp
7272
time_begin = time.time()
73-
# Writing input to process
74-
try:
75-
if len(self.stdin) > 0:
76-
proc.stdin.write(self.stdin)
77-
proc.stdin.flush()
78-
except BrokenPipeError:
79-
pass
8073
# Setting time limit
8174
thread_kill = [False, None]
8275
if self.time_limit > 0:
@@ -98,19 +91,10 @@ def time_delimiter(time_begin, time_limit, proc, thread_kill):
9891
target=time_delimiter,
9992
args=(time_begin, self.time_limit, proc, thread_kill)
10093
).start()
101-
# Waiting for process to terminate
102-
# stdout = b''
103-
# stderr = b''
104-
# while proc.poll() == None:
105-
# stdout += proc.stdout.read()
106-
# stderr += proc.stderr.read()
107-
# proc.stdout.flush()
108-
# proc.stderr.flush()
109-
# time.sleep(0.015)
94+
# Inputting and waiting for process to terminate
11095
try:
111-
stdout = proc.stdout.read()
112-
stderr = proc.stderr.read()
113-
except BrokenPipeError:
96+
stdout, stderr = proc.communicate(input=self.stdin)
97+
except Exception:
11498
stdout = b''
11599
stderr = b''
116100
ret_code = proc.wait()

0 commit comments

Comments
 (0)