irmen / Pyro5

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

Per call instance acts like session instance #35

Closed soyacz closed 3 years ago

soyacz commented 3 years ago

I've just copied example https://github.com/irmen/Pyro5/tree/master/examples/instancemode and It looks like per call instance behaves like session instance:

Showing the different instancing modes.
The number printed, is the id of the instance that handled the call.

-----PERCALL (different number possible every time) -----
139735247191632
139735247191632
139735247191632
139735247188896
139735247188896
139735247188896
139735247190720
139735247190720
139735247190720

As you can see, there are repetitions in each session.

My env: Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux pyro5 5.11 Remote object communication library, fifth major version robotframework 3.2.2 Generic automation framework for acceptance testing and robotic process automation (RPA) serpent 1.30.2 Serialization based on ast.literal_eval

irmen commented 3 years ago

What you're observing is Python reusing objects internally hence producing the same id for multiple instance creations. This is perfectly normal and not Pyro related.

To make it more clear, I've added a line to the instancemode server that reports when the server object gets constructed, and what (Python) object id it got. You'll see that for instancemode=single, a new object will be created every call. Commit: e0d8d8609d876df82cb66a140d785875461e4426

(thanks for the precise issue description btw)

soyacz commented 3 years ago

Thanks Irmen for explanation!