Can someone please explain me this really weird observation?
I've been trying to call Rx extension methods from inside IronPython and it is turning out to be simply impossible. I've boiled it down to this simple example:
import clr
clr.AddReference("System.Core")
from System.Linq import Enumerable
def process(value):
return Enumerable.Select(value, lambda x:x)
In this case we start with normal LINQ. If I call the process
function from my hosting environment with an array or any other IEnumerable
object, it works totally fine.
So then I tried to simply replace the references to use the Observable
extension methods like so:
import clr
clr.AddReference("System.Reactive.Linq")
from System.Reactive.Linq import Observable
def process(value):
return Observable.Select(value, lambda x:x)
In this case, if I call the process
function with an IObservable
object, the call crashes with an ugly error message:
expected IObservable[object], got Select[int, int]
Has anyone hit upon something like this? Have I missed something? Is there some special case hack to make Enumerable
work with lambda delegates that Observable
is missing? I have to admit I'm completely baffled here.
By the way, just as a sanity check, the following example works just fine:
import clr
clr.AddReference("System.Reactive.Linq")
from System.Reactive.Linq import Observable
def process(value):
return Observable.Sum(value)
I wanted to leave it out there just to make it clear that the problem really is in the method call to Observable.Select
.