Have embedded IronPython 2.7 in my app, and use clr.AddReference() to a managed .NET dll.
That DLL has async functions such as:
async public Task<string> Foo(string x) {
string y=await bar(x);
return y;
}
When called from IronPython I can see the Task object on the return but not the result of the call. Is there syntax to await the call? (Apologies if obvious: I'm a Python newbie...)
UPDATE: May not have been clear in the first version of the post what the problem is (and fixed a stupid typo in the code snippet). The function above works just fine (btw, don't ever use .Result as it causes deadlocks).
The challenge is getting the answer to Python. In IronPython, I call this function with:
f=mylib.Foo("hello")
And get back a Task (not a string) as the return value, which is correct. However, if I attempt this:
g=f.Result
It deadlocks (as expected). Does IronPython in any way support the same semantics as C#'s await?
var temp = await bar(); temp.Wait(); x = temp.Result;- Ingenioushax