Sometimes....
I have an RPC that works 90% of the time, and 10% of the time errors out with:
ImportError: No module named mymodule
The error is repeatable, a function call that errors will always error, and a function call that works will always work. I'm thinking it has to be argument related, but for the life of me I can't figure out what's going on.
Skipping details for brevity, the script module does some stuff, then makes the RPC. Importantly, data
is not modified in any way between the script function call and the RPC function call (the data
that arrives in the arguments goes straight to the arguments for the RPC).
override fun runAsync(name: String, data: Any) {
...
val handle = runAsyncRPC(name, data)
...
The actual RPC signature is:
fun runAsyncRPC(name: String, data: Any): AsyncRPCHandle
data class AsyncRPCHandle(
val function: String,
val id: String
) : java.io.Serializable
It's the data
argument that is giving me grief. It's typed as Any
so that it can take either a dictionary or an instance of a module-specific class.
Hopefully I'm not leaving too much out, but here's an example of the weirdness I'm seeing:
data1 = system.mymodule.makeData(...)
data2 = system.mymodule.makeDataAnotherWay(...)
type(data1) == type(data2) # True
data1 == data2 # True
from com.mymodule import MyDataClass
type(data1) == MyDataClass # True
type(data2) == MyDataClass # True
isinstance(data1, MyDataClass) # True
isinstance(data2, MyDataClass) # True
system.mymodule.runAsync('name', data1) # works
system.mymodule.runAsync('name', data2) # ImportError: No module named mymodule
At first I thought it was something to do with using Any
in the function signature so I tried changing the RPC signature to:
fun runAsyncRPC(name: String, data: MyDataClass): AsyncRPCHandle
just to see if it would help, but with no success.
Things look okay system.mymodule.makeDataAnotherWay(...)
function, there are no errors in the gateway, and everything looks good in the client up until the exact line of the RPC.
Any ideas?