irmen / Pyro5

Pyro 5 - Python remote objects
https://pyro5.readthedocs.io
MIT License
303 stars 36 forks source link

Reconnect to proxy doesn't connect to running object. #62

Closed ZhendongTian closed 2 years ago

ZhendongTian commented 2 years ago

This happens when I restart my python kernel, if I try to reconnect to the proxy by using Pyro5.api.Proxy('Pyro....') while passing the existing server uri, it seems to be starting a new object instead of using the old object. Is there any way to connect to the existing object instead?

irmen commented 2 years ago

Yes, as pointed out in the other issue too; there is the @behavior decorator https://pyro5.readthedocs.io/en/latest/servercode.html?highlight=instance#controlling-instance-modes-and-instance-creation

The default instance creation mode is to create a new server side object per proxy connection. If you want the same object instance for every connection, use instance_mode="single"