gen_server module - Handling gen:calls nicely¶
Example of how to inherit from GenServer:
class MyProcess(GenServer):
def __init__(self, node) -> None:
GenServer.__init__(self, node, accepted_calls=['hello'])
def hello(self):
return self.pid_
-
exception
pyrlang.gen_server.
GenException
(msg, *args, **kwargs)¶ Bases:
Exception
-
class
pyrlang.gen_server.
GenServer
(accepted_calls: Optional[list] = None)¶ Bases:
pyrlang.process.Process
Inherit from this instead of inheriting from the
Process
to gain the ability to convert incominggen:call
messages into regular Python method calls.-
gen_accepted_calls_
= None¶ List of strings with allowed messages which will be converted into method calls. A incoming call is identified by its first element (which must be atom, binary or string).
-
static
handle_info
(msg)¶ Similar to Erlang/OTP - handler receives all messages which were not recognized by gen message parser.
-
handle_one_inbox_message
(msg)¶ Function contains secret sauce - the
gen:call
parsing logic.
-