backend.py
This is the backend for the BackendAction. It's gets called by the following code of the BackendAction:
BackendAction.py (partial)
backend_path = os.path.join(os.path.dirname(__file__), "backend.py")
self.launch_backend(backend_path=backend_path)
backend.py itself looks like this:
backend.py
from streamcontroller_plugin_tools import BackendBase
import Pyro5.api
import time
import random
@Pyro5.api.expose
class Backend(BackendBase):
def __init__(self):
super().__init__()
def get_number(self):
return str(random.randint(0, 42))
if __name__ == "__main__":
backend = Backend()
Pyro5¶
If you are working with dedicated backends like this one it it important to understand that if will be executed in a completely dedicated python process. This means no normal communication or imports of any StreamController and action modules will be possible.
Instead the communication is done via Pyro5.
Read more in BackendAction#Pyro5.