-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoproxy lifetimes are broken #92
Comments
I think the daemon's shutdown() is never called and it remains running in the requestLoop(). |
The I clarified the code by waiting for the requestloop future to finish explicitly, however this produces the exact same result: @pytest.fixture
def proxy():
global _live_objects
_live_objects = set()
with ThreadPoolExecutor(max_workers=1) as e, Daemon() as daemon:
uri = daemon.register(Parent, force=True)
must_shutdown = False
fut = e.submit(daemon.requestLoop, lambda: not must_shutdown)
with Proxy(uri) as proxy1, Proxy(uri) as proxy2:
yield proxy1, proxy2
must_shutdown = True
fut.result() # <==== added
assert not _live_objects, "some objects were not cleaned up" The fixture approach using an executor is perhaps too complex. I can create a test example where the daemon requestloop runs inside a thread, would you prefer this approach? |
Followed your suggestion to use @pytest.fixture
def proxy():
global _live_objects
_live_objects = set()
with ThreadPoolExecutor(max_workers=1) as e, Daemon() as daemon:
uri = daemon.register(Parent, force=True)
fut = e.submit(daemon.requestLoop)
with Proxy(uri) as proxy1, Proxy(uri) as proxy2:
yield proxy1, proxy2
daemon.shutdown()
assert not _live_objects, "some objects were not cleaned up" |
Hmm... okay I was mistaken about the boolean It's been a few years since I wrote the unit-tests for pyro5, but there are a bunch in the test_server module that use a running daemon. Maybe I did something different there? |
I added a few simple (currently failing) tests that verify autoproxy lifetimes here: #93 Maybe these might be useful as a starting point to investigate the issue further? |
I'm trying to take an existing Python library, and allow it to be used remotely over the network. The library creates and returns Python objects which contain C library handles, so AFAIK they cannot be serialized, and need to be auto-proxied.
So far so good. But, I am running into trouble with autoproxy object lifetimes. When an autoproxy proxy handle goes out of scope, the corresponding server object is never released.
Some pytests which I believe should succeed, yet two fail. Edit:
python==3.12.3, Pyro5==5.15, pytest==8.2.2
The text was updated successfully, but these errors were encountered: