Skip to content
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

Unable to access Ultradict after a certain loop Limit, Issue occurs Only on Linux............. #9

Closed
hemakumar01 opened this issue May 21, 2022 · 4 comments

Comments

@hemakumar01
Copy link

from UltraDict import UltraDict

ultra = UltraDict({ 'init': 'some initial data' }, name='myname1')

for i in range(1,5000):
print(UltraDict(name='myname1'))

############### ERROR #################
File "/home/merit/miniconda3/lib/python3.9/site-packages/UltraDict/UltraDict.py", line 659, in unlink
self.control.unlink()
File "/home/merit/miniconda3/lib/python3.9/multiprocessing/shared_memory.py", line 241, in unlink
_posixshmem.shm_unlink(self._name)
FileNotFoundError: [Errno 2] No such file or directory: '/myname1'

@ronny-rentner
Copy link
Owner

Hi @hemakumar01

Thanks for your issue report. Can you please try the dev branch and see if this fixes your issue?

@ronny-rentner
Copy link
Owner

ronny-rentner commented May 22, 2022

PS: To add some explanation: With your code, you're creating and connecting 5000 new instances of an UltraDict to shared memory. There is a bug in the main branch that prevents proper cleanup of all file handles and at some point some of the OS resources are gone and you will start seeing random exceptions. Though, of course using UltraDict like this is not really an efficient way. You should keep around your instances (unless you also spawn 5000 new processes in the same time).

@hemakumar01
Copy link
Author

I tried the dev branch and the issue is now fixed, Thanks for the reply, out of curiosity, i didnt look into the dev code much, can you explain what was done to fix the issue.

@ronny-rentner
Copy link
Owner

ronny-rentner commented May 23, 2022

Sure, I've moved the cleanup code from an atexit handler to a finalizer and also implemented the __del__() method to correctly close the file handles again. The latter should help in your loop to close the file handles after each cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants