This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xdegaye
Recipients Pierrick.Koch, andy_js, giampaolo.rodola, xdegaye
Date 2013-05-29.12:40:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369831225.98.0.83470213569.issue17925@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is that when the fifo contains a producer and the more()
method of the producer returns a non-empty bytes sequence, then the
producer must be put back in the fifo first. This is what does the
following change made to Pierrick patch:

diff --git a/Lib/asynchat.py b/Lib/asynchat.py
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -229,6 +229,7 @@
             except TypeError:
                 data = first.more()
                 if data:
+                    self.producer_fifo.appendleft(first)
                     self.producer_fifo.appendleft(data)
                 continue

The asynchat test is OK when the patch is modified with the above
change.

However, then the patch does not make initiate_send() thread safe.
There is now a race condition: another thread may be allowed to run
between the two appendleft() calls, this other thread may then call
the more() method of 'first' and send the returned bytes. When that
happens, the sent data is mis-ordered.
History
Date User Action Args
2013-05-29 12:40:26xdegayesetrecipients: + xdegaye, giampaolo.rodola, Pierrick.Koch, andy_js
2013-05-29 12:40:25xdegayesetmessageid: <1369831225.98.0.83470213569.issue17925@psf.upfronthosting.co.za>
2013-05-29 12:40:25xdegayelinkissue17925 messages
2013-05-29 12:40:25xdegayecreate