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

Heroku keepalive is blocking the thread #3

Closed
jacobtomlinson opened this issue Oct 17, 2019 · 1 comment · Fixed by #4
Closed

Heroku keepalive is blocking the thread #3

jacobtomlinson opened this issue Oct 17, 2019 · 1 comment · Fixed by #4
Labels

Comments

@jacobtomlinson
Copy link
Member

jacobtomlinson commented Oct 17, 2019

Well this is a fun little bug.

In order to keep the Heroku Dyno alive there needs to be one request every 5 minutes. Therefore I added a skill that uses match_crontab to hit the status API every 5 minutes to keep itself awake.

However, I was lazy and just used requests (not async) to make a get request. This means that when opsdroid runs the skill it blocks the event loop on the requests call which stops the web server from being able to respond to the call and eventually times out.

The fix for this is to use aiohttp to make the call or run requests in an executor.

@jacobtomlinson
Copy link
Member Author

Hooray!

2019-10-17T08:40:00.944155+00:00 heroku[router]: at=info method=GET path="/stats" host=opsdroid-demo.herokuapp.com request_id=c8c40261-7521-43ca-a8e5-a717ef59552e fwd="54.170.47.168" dyno=web.1 connect=0ms service=2ms status=200 bytes=385 protocol=https
2019-10-17T08:40:00.909364+00:00 app[web.1]: DEBUG opsdroid.parsers.crontab: Running crontab skills at Thu Oct 17 08:40:00 2019
2019-10-17T08:40:00.942703+00:00 app[web.1]: INFO aiohttp.access: 10.12.152.238 [17/Oct/2019:08:40:00 +0000] "GET /stats HTTP/1.1" 200 385 "-" "Python/3.7 aiohttp/3.6.2"

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

Successfully merging a pull request may close this issue.

1 participant