This repository was archived by the owner on Oct 2, 2024. It is now read-only.
Conversation
kkuehlz
suggested changes
Jan 15, 2019
Member
kkuehlz
left a comment
There was a problem hiding this comment.
Nice. This is a really good change. I think for some of these operations the lock is being acquired too early. I left comments to explain.
| message, | ||
| ).encode('utf-8')) | ||
|
|
||
| # The message must be split up if over the length limit |
Member
There was a problem hiding this comment.
we only really need to acquire the lock here. you aren't using the connection when getting the message length
| ).encode('utf-8')) | ||
|
|
||
| # The message must be split up if over the length limit | ||
| if msg_len > MAX_CLIENT_MSG: |
Member
There was a problem hiding this comment.
can't we just simplify this logic and remove the if statement? with python slices , if we are less than MAX_CLIENT_MSG we will just have an array of size 1.
Then we can simplify the logic further and only acquire the lock before the loop
| return '{}: {}'.format(m.group(1), int(m.group(2)) + 1) | ||
| with self.sendmsg_lock: | ||
| for channel, topic in self.topics.items(): | ||
| def plusone(m): |
Member
There was a problem hiding this comment.
nit: would just make this a lambda
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The
irclibrary uses Python sockets, which aren't thread-safe. This PR adds a lock and acquires the lock for any operation that sends to the IRC server.