fix(server): dispatch callbacks and queue events - #856
Open
gijzelaerr wants to merge 1 commit into
Open
Conversation
NiklasReisser
left a comment
There was a problem hiding this comment.
To be honest, I don't fully understand the way pick_event is supposed to be used.
Should I busy wait in my application?
Or rather call pick_event in my callback to prevent the queue from overflowing?
| self.assertIsInstance(read_event, SrvEvent) | ||
| self.assertIsInstance(write_event, SrvEvent) | ||
| assert isinstance(read_event, SrvEvent) | ||
| assert isinstance(write_event, SrvEvent) |
There was a problem hiding this comment.
Why the duplicated check? Wouldn't it be more important to check the local events list filed by the callback?
|
|
||
| # Event queue for pick_event | ||
| self._event_queue: List[SrvEvent] = [] | ||
| self._event_lock = threading.Lock() |
There was a problem hiding this comment.
Consider using https://docs.python.org/3/library/queue.html to prevent the list from filling up too much. Also, you wouldn't need the lock.
This file contains hidden or 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
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.
Summary
Validation
Addresses #853.