Author xdegaye
Recipients Pierrick.Koch, giampaolo.rodola, xdegaye
Date 2013-05-09.19:19:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368127195.3.0.062600621041.issue17925@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2013-05-09 19:19:55xdegayesetrecipients: + xdegaye, giampaolo.rodola, Pierrick.Koch
2013-05-09 19:19:55xdegayesetmessageid: <1368127195.3.0.062600621041.issue17925@psf.upfronthosting.co.za>
2013-05-09 19:19:55xdegayelinkissue17925 messages
2013-05-09 19:19:55xdegayecreate