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

fix for multi user scenario #3118

Merged
merged 2 commits into from
Dec 20, 2019
Merged

Conversation

xieofxie
Copy link
Contributor

They are not thread-safe when multiple users call these functions.

Also we must use services.AddSingleton<IBot, TestBot>() for the state of RandomSelector._rand

@coveralls
Copy link
Collaborator

coveralls commented Dec 10, 2019

@boydc2014
Copy link
Contributor

Looks good to me, Random.Next is not thread-safe. Request Tom and ChrisMc to review and confirm.

@xieofxie do you have a scenario that multi-thread is used, maybe we can check in with some tests if it's a typical use case?

@xieofxie
Copy link
Contributor Author

@boydc2014 Unfortunately, after some searching, I didn't find examples about how to write tests for concurrency.

I write one myself here xieofxie@79c86cc, but it looks not good enough for me.

Typically this happens when bot is used by multiple users and they happen to run into same functions.

Copy link
Contributor

@chrimc62 chrimc62 left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@tomlm tomlm left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants