Comment 19 for bug 887861

Revision history for this message
Kartik Singhal (kartiksinghal) wrote :

Pasting comment 16 here, it's not available anymore at that link:

Tried properly debugging this time with some tracing:

Around this
https://bazaar.launchpad.net/~conscioususer/polly/unstable/view/head:/src/polly/twitter/realtime.py#L421

                if buffer_starting:
                    for subdata in data:
                        print u'DEBUG: reading 2nd subdata'
                        self.account.shelf.set_friend(subdata)
                    print u'DEBUG: deleting 2nd data[:]'
                    del data[:]

The first time del data[:] is called, it works. data is a list as expected in that case. The second time contents of data becomes a dict and we get:

DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: deleting 2nd data[:] <-------------- first call successful
DEBUG: k4rtik connected successfully

DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: deleting 2nd data[:] <-------------- second call error
Exception in thread Thread-13:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 811, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/site-packages/polly/__init__.py", line 241, in run
    self.callback(*self.args)
  File "/usr/lib/python2.7/site-packages/polly/twitter/realtime.py", line 423, in _buffer_loop
    del data[:]
TypeError: unhashable type

This is always reproducible. I tried adding try/except around del
dict[:] and removing del dict[:] altogether, but then another error
appears at same position:

DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: k4rtik connected successfully

DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
DEBUG: reading 2nd subdata
Exception in thread Thread-13:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 811, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/site-packages/polly/__init__.py", line 241, in run
    self.callback(*self.args)
  File "/usr/lib/python2.7/site-packages/polly/twitter/realtime.py", line 427, in _buffer_loop
    self.account.backend.release_connecting()
  File "/usr/lib/python2.7/site-packages/polly/twitter/account.py", line 1361, in release_connecting
    self.connecting_lock.release()
error: release unlocked lock

Had some discussion about this behavior on #python, folks there pondered
on why threads are being used for a twitter client and concluded it's
some kind of race condition. Will be able to help fix this issue as I
have a reproducible test case.