-
Notifications
You must be signed in to change notification settings - Fork 354
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
adding session manager #943
Conversation
Wrong target branch, please point to develop |
oh you're right, sorry, I'll fix it |
8bc5cfc
to
6901632
Compare
Awesome. |
074fb78
to
dd49557
Compare
dd49557
to
9b50dc2
Compare
@scicco tried to do a review but I guess we must pseudocode first and have a better design (my bad). I should also explain to you a few things on cat inner workings ;) Thanks a lot, sorry for closing let's try again |
@@ -111,6 +144,10 @@ async def get_user_stray(self, user: AuthUserInfo, connection: Request) -> Stray | |||
# TODOV2: user_id should be the user.id | |||
user_id=user.name, user_data=user, main_loop=event_loop | |||
) | |||
|
|||
self.refresh_user_expiration(connection, user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @scicco thanks
Does not sound good to me that this methods are called from all child classes
Can't they be run in parent class at Connection.__call__
jut after get_user_stray
is called?
Let me know if I'm not getting something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, it's better to move them on parent class
|
||
# then we create a new session | ||
self.sessions[current_time] = {"user_id": user.id, "name": user.name} | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why pass
? It does nothing ;)
|
||
current_time = datetime.now(timezone.utc) + timedelta(minutes=minutes) | ||
|
||
# if user_id is already in the session we removed it first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having a hard time understanding what you are doing here
also, self.strays
is already a dictionary in which keys are the id? Why loop over timestamps, if they are not even sorted? Sorry cannot understand
# user: test4 will expire after 4 minutes | ||
# and so on | ||
# | ||
if "test" in user.name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot accept this sorry 😔
Tests should not be in cat code, should be in the test suite
Description
This commit attempts to clean old strays after some time. Currently, the expiration check is accomplished every time a new connection is made.
Related to issue #846
How to test this
test<n>
wheren
means the amount of minutes before expiration if no new connection is performedtest<n>
on a tabn
minutesadmin
on another tabtest<n>
tab: the previous "session " oftest<n>
should be cleaned (the chat history should be empty)What is missing
Currently, the cleanup and the refresh of sessions happen only when a new connection is done. We need also to refresh the expiration when a user's message arrives. I need some guidance to understand where is the right place to invoke refresh on the code, I think the call should go in some line of
core/core/cat/looking_glass/stray_cat.py
Line 322 in f14f2c0
Type of change
Checklist: