Skip to content
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

bot: keep track of trigger processing threads #1732

Merged
merged 1 commit into from
Nov 22, 2019

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Nov 2, 2019

Based on #1728 to avoid future merge conflict.

My initial idea was to join trigger processing threads directly in the dispatch method. For several reasons (including the echo-message polyfill), that's not doable.

Instead, since all I want is a way to know, access, and join processing threads in automated tests, I make sure the bot keeps track of its threads. This way, I'll be able to run a dispatch, going through all the bot's internals and machineries, and then wait for the end result in my tests.

It was a bit convoluted, but in the end I think it turned out great!

Quick note about memory consumption: this information generate a very low overhead, since running threads are kept in memory anyway by Python. All that is stored is a reference to the thread object, and every time dispatch is called, the list is flushed out of obsolete running threads.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. As long as it won't lead to any appreciable performance decrease, I see no reason not to keep track of stuff for testing and debugging purposes.

My guess is that looping through the list of running triggers will be quite fast, so it's not really a concern. That list should never get anywhere near a large enough size to cause lock contention.

sopel/bot.py Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
sopel/bot.py Show resolved Hide resolved
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fat-fingered the "Approve" button, when clearly my previous review was requesting changes. To everyone watching this repo: Sorry for the double email!

@Exirel
Copy link
Contributor Author

Exirel commented Nov 19, 2019

I rebased to fix the conflict, but I'll wait until #1728 is merged before fixing the remaining issues.

@Exirel Exirel force-pushed the dispatch-thread-join branch 2 times, most recently from 157c5e5 to 73c6312 Compare November 20, 2019 21:48
sopel/bot.py Show resolved Hide resolved
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like I missed a few things in my last review. But I guess it's OK, because it means I can try to sneak in a log format change since you're touching that line anyway. 😝

sopel/bot.py Outdated Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
sopel/bot.py Outdated Show resolved Hide resolved
@Exirel Exirel requested a review from dgw November 21, 2019 09:24
@Exirel
Copy link
Contributor Author

Exirel commented Nov 21, 2019

All fixed (again). Waiting for a go to squash.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Exirel I reviewed the commits addressing my comments. Go for squash!

@Exirel
Copy link
Contributor Author

Exirel commented Nov 21, 2019

Done.

@dgw dgw merged commit 8333360 into sopel-irc:master Nov 22, 2019
@Exirel Exirel deleted the dispatch-thread-join branch January 14, 2020 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants