svgui/pyjs/jsonrpc/web2py/jsonrpc.py
author Edouard Tisserant
Tue, 25 May 2021 15:05:38 +0200
changeset 2738 58f2e3f22934
parent 1881 091005ec69c4
permissions -rw-r--r--
Runtime: Fix exception "Worker is disabled" when connecting while PLC runtime is starting.

Pyro/wamp/UI delegate jobs to Worker, causing race condition if worker isn't already started.
Added a function to ensure that Worker is already created when pyro or UI starts
# pylint: disable=undefined-variable

from __future__ import absolute_import
from svgui.pyjs.jsonrpc.jsonrpc import JSONRPCServiceBase


class JSONRPCService(JSONRPCServiceBase):

    def serve(self):
        return self.process(request.body.read())

    def __call__(self, func):
        self.methods[func.__name__] = func
        return func