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
Add support for "Session resuming" & "session data queueing". #59
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added Queue which is only sent if a session is restored or has a chance that it might be restored - Modified backoff to try connecting twice to lavalink server before session is closed - Resume key is generated with secret.choice and defaults to 32 character, if No resume key is passed - Changes are not breaking since all added args are optional
Version number not changed yet. |
line 183, 185 change to multiple assignment.
Could you review this? |
switched to a subclassed Timed asyncio.Queue
I have switched to asyncio.Queue(ish), could you re-review? |
_TimedQueue Test (Edited due to recent commit)from wavelink import _TimedQueue # Modified __init__
import time
import asyncio
if __name__ == '__main__':
a = _TimedQueue(0, timeout=6.0)
a.put_nowait("aight")
time.sleep(7.0)
print(a.get_nowait()) # None
a.put_nowait("hmmm")
a.clear()
try:
a.get_nowait()
except asyncio.QueueEmpty:
print("Excepted") # Queue should be cleared.
a.put_nowait("This should be printed.")
time.sleep(3.0)
print(a.get_nowait()) Output
|
WizzyGeek
changed the title
Add support for "Session resuming", "session data queueing" and Cleanup.
Add support for "Session resuming" and "session data queueing".
Jun 30, 2020
the default value was weak
WizzyGeek
changed the title
Add support for "Session resuming" and "session data queueing".
[Req-to-Review] Add support for "Session resuming" & "session data queueing".
Aug 3, 2020
Sync to 0.9.4 for use
Revert "Sync to 0.9.4 for use"
Revert "Revert "Sync to 0.9.4 for use""
WizzyGeek
changed the title
[Req-to-Review] Add support for "Session resuming" & "session data queueing".
Add support for "Session resuming" & "session data queueing".
Aug 13, 2020
WizzyGeek
added a commit
to WizzyGeek/Wavelink
that referenced
this pull request
Aug 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is Implemented in #66
Added New attributes
Websocket.reset()
method.What are the new features?
Websocket queueing.
Websocket._send()
method now queues any data that is requested to be sent while the WS is disconnected.Websocket.send_queue()
which is called when connecting, and sends queue only when a session is resumed and Websocket is connected.Resuming
'resume_session': True
Though the former has more use cases by using a Key Object we can:
__str__
is called when configuring the server, while__repr__
is called when the Node's session is closed to generate a new key.How does resuming work?
When the bot disconnects from the node (eg: 1006) then the lavalink server keeps on playing the music until session timeout, this allows the bot to reconnect and take control of the session. This PR implements this lavalink feature.
The changes are not breaking, assuming no-one initializes Node instances directly.
How does Queueing work?
After the Node disconnects, we try to reconnect twice before timeout. during this time the requests to the node are queued in an
asyncio.Queue
subclass whose payload expires after some time.This could be useful when you have an higher timeout but want to only send recent requests