Page MenuHomePhabricator

site_rc_listener does not have any events after some time
Closed, DeclinedPublic

Description

From time to time site_rc_listener does not have any events but no error occurs.

the code snippet looks like:

import pywikibot
from pywikibot.comms.rcstream import site_rc_listener
site = pywikibot.Site()
rc_listener = site_rc_listener(site)
while True:
    for entry in rc:listener:
        if entry['type'] == 'edit': break

Event Timeline

And the wiki definitely had events after the listener stopped?
We should be able to increase the logging level on this package to see what
is happening , or logging in requests for the rc site to see the raw view
of the connection.

Very likely an Upstream bug in the python library or the wmf servers

I don't expect that the listener stops because the script runs in infinite loops. But if it stops I would expect some kind of exception. I changed the debugging lines to get additional information when the next failure occurs.

jayvdb changed the task status from Open to Stalled.Jun 8 2016, 2:36 PM

Last time I got

Waiting for events......................No handlers could be found for logger "socketIO_client"

after about 15 hours. No events where retrieved anymore.

After 5 days I had again:
Waiting for events...No handlers could be found for logger "socketIO_client"
without any event received.

Change 295117 had a related patch set uploaded (by Xqt):
[bugfix] Add a watchdog to restart rc listener threat

https://gerrit.wikimedia.org/r/295117

Patch works for me:

Waiting for events.....No handlers could be found for logger "socketIO_client"
WARNING: rcstream thread restarted due to watchdog timeout.
(u'RCS: self.client.connected is', True)
RCS: Shut down event loop for <rcstream for socketio://de.wikipedia.org@stream.wikimedia.org:80/rc>
Waiting for events..................
Xqt triaged this task as High priority.Jun 20 2016, 7:46 AM
>> 14:10:03:

Waiting for events...............WARNING: rcstream thread restarted due to watch
dog timeout.
(u'RCS: self.client.connected is', True)
RCS: Shut down event loop for <rcstream for socketio://de.wikipedia.org@stream.w
ikimedia.org:80/rc>
No handlers could be found for logger "socketIO_client"
Exception in thread Thread-3:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 810, in __bootstrap_inner
    self.run()
  File "C:\pwb\core\pywikibot\comms\rcstream.py", line 150, in run
    self.client.wait(seconds=0.1)
  File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 255, in wait
    next(self._heartbeat_pacemaker)
  File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 390, in _make_heartbeat_pacemaker
    self._transport.send_heartbeat()
  File "C:\Python27\lib\site-packages\socketIO_client\transports.py", line 60, in send_heartbeat
    self.send_packet(2)
  File "C:\Python27\lib\site-packages\socketIO_client\transports.py", line 89, in send_packet
    self.send(packet_text)
  File "C:\Python27\lib\site-packages\socketIO_client\transports.py", line 218, in send
    timeout=TIMEOUT_IN_SECONDS)
  File "C:\Python27\lib\site-packages\socketIO_client\transports.py", line 320, in _get_response
    raise TimeoutError(e)
TimeoutError: HTTPConnectionPool(host='stream.wikimedia.org', port=80):
Max retries exceeded with url: /socket.io/1/xhr-polling/407231568979?t=1466424854
(Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x000000000453F080>,
'Connection to stream.wikimedia.org timed out. (connect timeout=3)'))

WARNING: rcstream thread restarted due to watchdog timeout.
Xqt changed the task status from Stalled to Open.Apr 23 2017, 8:40 AM
Xqt lowered the priority of this task from High to Lowest.

rcstream will be removed by EventStreams soon

The given patch works like this:

Waiting for events...No handlers could be found for logger "socketIO_client"
WARNING: rcstream thread restarted due to watchdog timeout.
Waiting for events.......

RCStream is deprecated and declared to be switched off soon. Use EventStreams instead.

Change 295117 abandoned by Xqt:
[bugfix] Add a watchdog to restart rc listener thread

Reason:
RCStream is deprecated and declared to be switched off soon. EventStreams should be used instead.

https://gerrit.wikimedia.org/r/295117