Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite891365

Browse files
committed
sleep
1 parent790daa7 commite891365

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

‎core/checker.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
importast
22
importinspect
33
importlogging
4+
importtime
45
fromcollectionsimportdefaultdict
56

67
fromcore.exercisesimportassert_equal
@@ -50,7 +51,7 @@ def non_str_input(self):
5051

5152

5253
@catch_internal_errors
53-
defcheck_entry(entry,input_callback,output_callback):
54+
defcheck_entry(entry,input_callback,output_callback,sleep_callback=time.sleep):
5455
result=dict(
5556
passed=False,
5657
messages=[],
@@ -76,7 +77,11 @@ def full_output_callback(data):
7677
data["parts"]=parts
7778
returnoutput_callback(data)
7879

79-
runner.set_combined_callbacks(output=full_output_callback,input=input_callback)
80+
runner.set_combined_callbacks(
81+
output=full_output_callback,
82+
input=input_callback,
83+
sleep=sleep_callback,
84+
)
8085
runner.question_wizard=entry.get("question_wizard")
8186
runner.input_nodes=defaultdict(list)
8287

‎core/runner/runner.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
frompython_runnerimportPatchedStdinRunner
1+
frompython_runnerimportPatchedStdinRunner,PatchedSleepRunner
22

33

4-
classEnhancedRunner(PatchedStdinRunner):
4+
classEnhancedRunner(PatchedStdinRunner,PatchedSleepRunner):
55
defexecute(self,code_obj,source_code,mode=None):
66
ifmode=="snoop":
77
fromcore.runner.snoopimportexec_snoop

‎frontend/package-lock.json‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎frontend/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"redux-logger":"^3.0.6",
3737
"redux-thunk":"^2.3.0",
3838
"sass":"^1.32.8",
39-
"sync-message":"0.0.2"
39+
"sync-message":"0.0.3"
4040
},
4141
"scripts": {
4242
"start":"craco start",

‎frontend/src/Worker.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import*asComlinkfrom'comlink';
66
importpythonCoreUrlfrom"./python_core.tar.load_by_url"
77
importloadPythonStringfrom"!!raw-loader!./load.py"
8-
import{readChannel}from"sync-message";
8+
import{readChannel,syncSleep}from"sync-message";
99

1010
asyncfunctiongetPackageBuffer(){
1111
constresponse=awaitfetch(pythonCoreUrl);
@@ -90,7 +90,12 @@ async function runCode(entry, channel, interruptBuffer, outputCallback, inputCal
9090
constfullOutputCallback=(data)=>{
9191
outputPromise=outputCallback(toObject(data).parts);
9292
};
93-
constresult=check_entry(entry,fullInputCallback,fullOutputCallback);
93+
94+
functionsleepCallback(data){
95+
syncSleep(toObject(data).seconds*1000,channel);
96+
}
97+
98+
constresult=check_entry(entry,fullInputCallback,fullOutputCallback,sleepCallback);
9499
awaitoutputPromise;
95100
returntoObject(result);
96101
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp