From the client side, I call function “A” on the server.
The function “A” calls function “B”.
Function “B” returns a Pandas Dataframe to function “A”:
Function “A” processes the Pandas Dataframe returned by function “B”.
The problem is that I cannot get function “B” to return the dataframe to function “A”. I think there is some kind of limitation in the Anvil servers.
The error I get back is the following:
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize dictionaries with keys that aren’t strings at msg[‘response’]][‘review’][0]
Any suggestions or alternatives to solve this problem?
You might want to show the code for the functions in question to get concrete help. The error message you’re getting shouldn’t be happening with a return from one server function to another in the same server module, it should only happen when a server function tries to return the data frame to the client.
Most likely, function “A” is using anvil.server.call() to call function “B”. If both functions reside in the same program at the same time – e.g., both are Server functions in the same App – then “A” can call “B” directly, using standard Python syntax. No “serialization” required.
If “B” is an Uplink function, then “B” resides on a different computer from “A”. Then “A” would need anvil.server.call().
I am trying to call function b with anvil.server.call… Could this be causing the problem?
The Function B is in ServerModule2 and function A is in ServerModule1. This is so, because in the original application ServerModule1 has too many lines of code and the help to write variables (it takes time to load the many variables) is slowing down Writing Code
Yes, as Phil noted, when calling a server function from inside a server function in the same app, you do not need anvil.server.call. Just call the function as normal.
Since function_b is in another server module, you will need to import the function into the module that has function_a in it. Start typing from . and pick the right module.