Xavier de Gaye added the comment:
The attached script, test_initiate_send.py, tests initiate_send with
threads, causing duplicate writes and an IndexError. This is the
script output using python on the default branch:
$ python test_initiate_send.py
--- Test: duplicate data sent ---
chat.send('thread data')
chat.send('thread data')
--- Test: IndexError ---
chat.send('thread data')
chat.send('thread data')
Exception in thread Thread-2:
Traceback (most recent call last):
File "Lib/threading.py", line 644, in _bootstrap_inner
self.run()
File "Lib/threading.py", line 601, in run
self._target(*self._args, **self._kwargs)
File "test_initiate_send.py", line 25, in <lambda>
thread = threading.Thread(target=lambda : chat.push('thread data'))
File "Lib/asynchat.py", line 194, in push
self.initiate_send()
File "Lib/asynchat.py", line 254, in initiate_send
del self.producer_fifo[0]
IndexError: deque index out of range
The script does not fail with Pierrick patch:
$ python test_initiate_send.py
--- Test: duplicate data sent ---
chat.send('main data')
chat.send('thread data')
--- Test: IndexError ---
chat.send('thread data')
The patch misses to also appendleft() 'first' when 'num_sent' is zero,
which may happen on getting EWOULDBLOCK on send().
----------
nosy: +xdegaye
Added file: http://bugs.python.org/file30186/test_initiate_send.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17925>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com