Specifying module members
The first step in our creation of the backend module is to specify what
objects we want to make available for the remote procedure call. You find that
workflow in the source code of the backend modules
create_model()
method.
In our example we used the __all__
variable:
__all__ = ["hello_world"]
In fact, there are two possible ways to specify what should be available for the RPC:
using the
__all__
module variable (as we do above). The__all__
variable is commonly used when using import statements likefrom mymodule import *
(see the python docs), but it’s also a good way to tell other developers about the important functions and methods in your code.The second possibility is specifying the members in the call to the
main()
function, e.g.main(members=["hello_world"])
ormain(members=[hello_world])
. This would then take precedence over the__all__
variable of the module.