Closed AnSq closed 9 years ago
The recent meltdown of the bot was caused by improper exception handling of a ConnectionError
in post.add_comment(comment)
(full stack trace below). The comment posted correctly, but the error made it so it wasn't recorded in the database, causing the bot to think the post failed, so it would continuously retry. https://github.com/AnSq/IRCR_Info_Bot/compare/9793d4dbd161a26e95bef0d28b7778b8e52bbd51...e0b7cb9dd0a52ac5c731e67753a58e0b646a923a fixed the exception handling and database update, but the error was still generated, causing distinguishing to break. Reverting the recent PRAW update (https://github.com/AnSq/IRCR_Info_Bot/commit/332ee4c9d8954c86e8fbc61db4f6dd34fa9ebc4a reverted by https://github.com/AnSq/IRCR_Info_Bot/commit/858db51dba9250222eea79cb7dbeffe692df9ff4) seems to have fixed everything. It looks like it was a bug in the requests
package.
Stack trace of ConnectionError
:
2015-04-30T05:41:23.960494+00:00 app[worker.1]: --------------------------------
...23.960500+...: *** ERROR: ConnectionError: ('Connection aborted.', ResponseNotReady())
...23.960502+...: Traceback (most recent call last):
...23.960529+...: File "IRCR_Info_Bot.py", line 680, in main
...23.960572+...: scanSub(r, db, pg, testmode, mod_list)
...23.960576+...: File "IRCR_Info_Bot.py", line 666, in scanSub
...23.960601+...: post_comment(post, comment, db, testmode)
...23.960605+...: File "IRCR_Info_Bot.py", line 616, in post_comment
...23.960624+...: newcomment = post.add_comment(comment)
...23.960628+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/objects.py", line 1019, in add_comment
...23.960662+...: response = self.reddit_session._add_comment(self.fullname, text)
...23.960666+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/decorators.py", line 338, in wrapped
...23.960691+...: return function(cls, *args, **kwargs)
...23.960695+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 2173, in _add_comment
...23.960722+...: retry_on_error=False)
...23.960726+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/decorators.py", line 163, in wrapped
...23.960748+...: return_value = function(reddit_session, *args, **kwargs)
...23.960752+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 561, in request_json
...23.960778+...: retry_on_error=retry_on_error)
...23.960782+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 402, in _request
...23.960806+...: response = handle_redirect()
...23.960810+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 375, in handle_redirect
...23.960835+...: timeout=timeout, **kwargs)
...23.960839+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/handlers.py", line 144, in wrapped
...23.960870+...: result = function(cls, **kwargs)
...23.960872+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/handlers.py", line 54, in wrapped
...23.960894+...: return function(cls, **kwargs)
...23.960897+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/handlers.py", line 99, in request
...23.960924+...: allow_redirects=False)
...23.960928+...: File "/app/.heroku/python/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
...23.960954+...: r = adapter.send(request, **kwargs)
...23.960958+...: File "/app/.heroku/python/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
...23.960987+...: raise ConnectionError(err, request=request)
...23.961001+...: ConnectionError: ('Connection aborted.', ResponseNotReady())
...23.961004+...: --------------------------------
Unrelated to the meltdown, there was also an AttributeError
generated in the CommentScanner
(stack trace below). This also appears to have gone away with the revert.
Stack trace of AttributeError
:
2015-04-30T02:08:04.028685+00:00 app[worker.1]: --------------------------------
...04.028691+...: *** ERROR: AttributeError: _request_url
...04.028710+...: Traceback (most recent call last):
...04.028740+...: File "IRCR_Info_Bot.py", line 204, in scan
...04.028779+...: for comment in generator:
...04.028784+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 508, in get_content
...04.028820+...: page_data = self.request_json(url, params=params)
...04.028822+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/decorators.py", line 163, in wrapped
...04.028839+...: return_value = function(reddit_session, *args, **kwargs)
...04.028843+...: File "/app/.heroku/python/lib/python2.7/site-packages/praw/__init__.py", line 566, in request_json
...04.028873+...: delattr(self, '_request_url')
...04.028893+...: AttributeError: _request_url
...04.028895+...: --------------------------------
I hit a simliar error - that's with an anonymous reddit session that pulls submissions.
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
self.run()
File "/usr/lib/python3.2/threading.py", line 693, in run
self._target(*self._args, **self._kwargs)
File "/home/darkmio/python/MassdropBot/core/MassdropBot.py", line 99, in submission_thread
for submission in self.submissions:
File "/usr/local/lib/python3.2/dist-packages/praw/helpers.py", line 137, in _stream_generator
for i, item in gen:
File "/usr/local/lib/python3.2/dist-packages/praw/__init__.py", line 524, in get_content
page_data = self.request_json(url, params=params)
File "/usr/local/lib/python3.2/dist-packages/praw/decorators.py", line 173, in wrapped
return_value = function(reddit_session, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/praw/__init__.py", line 584, in request_json
delattr(self, '_request_url')
AttributeError: _request_url
Done by 49c052c95770905ea829c905ed51c1bdc5f4e54b.
Version 2.1.19 of praw is outdated. Version 2.1.21 was released Thursday March 26, 2015.