-
Notifications
You must be signed in to change notification settings - Fork 1
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
Orphan session files remain in session folder #1
Comments
Unable to create new branch for pull request, see code below for a background thread that checks and removes expired files
|
Hi @eycheu . Yes. You are right. I had considered this case. But I don't think it is a good idea to run such a thread in the asynchronous environment. As far as I know, all the official storages (cookie storage, memcached storage, redis storage, etc.) and known third party extensions (mongodb storage, dynamodb storage) have their own mechanism to clean up expired data automatically outside of the libraries. So I think the better way is to write a script to periodically clean up the expired session files outside of this tiny library (e.g. a cron job for the clean-up script). But for short-running applications I think the clean-up task can be done while startup. |
Hi @zhangkaizhao , would you be able to point to me the document or code in aiohttp-session that is doing the cleanup. I didn't find abstract method from AbstractStorage that we need to implement for the cleanup. I could have simply run another process or thread (not using the coroutine in a new asyncio loop of that thread) in reading out the expiration. By the way, pathlib unlink method for python 3.8 has an additional keyword argument missing_ok. I had issue running on Python 3.7. I am using tempfile as your example to hook into aiohttp.web on_cleanup and on_shutdown to remove the temporary folder and content. |
Oh! There must be a understanding. I meant the memcached server, redis server, mongodb server, HTTP client-side cookie management, etc. themselves all have their own mechanism for expiry clean-up but not the corresponding aiohttp-session extensions. |
Good catch! Yes. There is no keyword argument |
After some investigations I think there is no need to check the expiration file after loading cookie and the related lines are commented out. And a note of cleaning up expiry session files is added to README file. |
Revert checking session expiration after loading cookie. |
The example shows the use of aiohttp.web on_cleanup trigger to remove the temporary session directory and contents within it. Orphan files will remain in the session folder as long as aiohttp is not cleaned up even the corresponding sessions have expired. Would like to have the following features :
Suggession: Filename of file could have the expired time and an OS file wild card query to easily identify expired session and remove those files (hence not necessary to use another .expiration file to store the time session is going to expire).
The text was updated successfully, but these errors were encountered: