Anvil Uplink as Agents

Not sure if I understand exactly, but here goes anyway …

When you decorate a function with @anvil.server.callable you can optionally specify the name the function is published as. For example :

@anvil.server.callable("dave")
def myfunctioncalledsomethingelse():
   ...

would be called like this :

anvil.server.call("dave")

So, when your uplink service starts, generate a random name for your function and use that in your decorator. Then make sure the first thing your function does is to call a server function with that name as a parameter which adds that name to a table.

In that table you then have an enumerable list of attached uplink functions.

You can’t tell (as far as I know) when an uplink function goes away, so what I do is wrap all calls to those functions in a try...except block, and delete the table row if it fails.

Is that any help to you?

4 Likes