IronLanguages / IronLanguages/ironpython3
How to wait something
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
I try waiting a function,but the process make an error "Cannot wait on monitors on this runtime."
See the following example.
public class Seth(){
main(){
molding = "a = Utility.Readline_core("a")"
var u = new Utility();
var runtime = Python.CreateRuntime();
runtime.IO.SetInput(new MemoryStream(), Encoding.Default);
var eng = Python.GetEngine(runtime);
var scope = eng.CreateScope();
scope.SetVariable("Utility", u);
var source = eng.CreateScriptSourceFromString(molding);
eng.Execute(molding, scope);
}
}
public class Utility
{
private static async Task<string> Readline_core(object m = null)
{
if (m != null || m != string.Empty)
{
oncheng_input(m.ToString());
}
else
{
oncheng_input("何かを入力してください");
}
while (true)
{
if (import_temp != string.Empty)
{
Console.WriteLine(import_temp);
break;
}
await Task.Delay(1000);
}
var result = import_temp;
import_temp = string.Empty;
return result;
}
}
Here is Error
System.PlatformNotSupportedException: Cannot wait on monitors on this runtime. at System.Threading.Monitor.ObjWait(Int32 millisecondsTimeout, Object obj) at
System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout) at
System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at
System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at
System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken) at
System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at
System.Threading.Tasks.Task`1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetResultCore(Boolean waitCompletionNotification) at
System.Threading.Tasks.Task`1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Result() at
Ferrum.Utility.Input(String mess) in C:\Users\takum\Git\GitHub\Iron_ide\BlazorApp1\Ide\scripts\Seth.cs:line 200 at Microsoft.Scripting.Interpreter.FuncCallInstruction`2[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at
Microsoft.Scripting.Interpreter.LightLambda.Run4[CallSite,CodeContext,Object,Object,Object](CallSite arg0, CodeContext arg1, Object arg2, Object arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[CodeContext,Object,Object,Object](CallSite site, CodeContext arg0, Object arg1, Object arg2) at
Microsoft.Scripting.Interpreter.DynamicInstruction`4[[IronPython.Runtime.CodeContext, IronPython, Version=3.4.0.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1],[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(InterpretedFrame frame) at
Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at
Microsoft.Scripting.Interpreter.LightLambda.Run2[CodeContext,FunctionCode,Object](CodeContext arg0, FunctionCode arg1) at
IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at IronPython.Compiler.PythonScriptCode.Run(Scope scope) at
IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at
Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Execute(Scope scope) at
Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) at Microsoft.Scripting.Hosting.ScriptEngine.Execute(String expression, ScriptScope scope) at Ferrum.Coder.Mold() in C:\Users\takum\Git\GitHub\Iron_ide\BlazorApp1\Ide\scripts\Seth.cs:line 80
What can I do to fix this problem
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the embedded execution path in Seth.cs around lines 80 and 200, especially Utility.Readline_core and the Task.Result access shown in the trace. Reproduce the failure with the provided IronPython runtime setup and determine whether the wait is supported in this runtime. Done means the cause and a compatible resolution or confirmed runtime limitation are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100