Xavier de Gaye added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17925> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com