set_behavior

set_behavior#

method

classmethod Service.set_behavior(instance_mode: str = 'session', instance_creator: Callable | None = None) None[source]#

Sets the Pyro5 behavior for the class (modified in place).

Equivalent to using the behavior decorator on the class, but can be used dynamically during runtime. Services that specify some default behavior in the source code can be overridden using this function.

Parameters:
instance_modestr

One of “session”, “single”, or “percall” (see manual for differences).

instance_creatorcallable

A callable that creates a new instance of the class (see manual for more details).

Raises:
ValueError

If instance_mode is not one of “session”, “single”, or “percall”.

TypeError

If instance_mode is not a string or instance_creator is defined but is not callable.