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 100% CPU usage in async examples #206

Merged

Conversation

felixbuenemann
Copy link
Contributor

This switches from the endless loop to accumulating and joining the threads.

@felixbuenemann
Copy link
Contributor Author

Another approach would be to insert something like sleep 0.1 into the loop, but I think this one is both more correct and more instructive, since it shows that start_async returns a thread.

I only tested this code with the celluloid implementation when fixing will/slacktyping#1, but the EventMachine implementation also returns a thread so it should be fine.

This switches from the endless loop to accumulating and joining the
threads.
@felixbuenemann felixbuenemann force-pushed the fix-async-example-high-cpu-usage branch from a3c5be6 to 6ee4434 Compare April 29, 2018 09:48
@felixbuenemann
Copy link
Contributor Author

Added suggested changelog entry.

@dblock
Copy link
Collaborator

dblock commented Apr 29, 2018

Thanks! Looks like build failed for something unrelated, a library upgrade, simple replacement of post by POST in the expectation. Mind fixing that here too?

@felixbuenemann
Copy link
Contributor Author

Fixed the request logging spec.

@dangerpr-bot
Copy link

1 Message
📖 We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!

Generated by 🚫 danger

@dblock dblock merged commit 07a854d into slack-ruby:master Apr 30, 2018
@dblock
Copy link
Collaborator

dblock commented Apr 30, 2018

Thanks

@dblock
Copy link
Collaborator

dblock commented Apr 30, 2018

Btw, I am pretty sure I had Thread.pass on purpose here and not a join, at least in EventMachine times. If you have a moment, do actually please test the EM version?

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.

3 participants