Intermittent bug with asyncio and MS Edge

Frank Millman frank at chagford.com
Sun Mar 22 05:41:09 EDT 2020


On 2020-03-22 11:00 AM, Barry Scott wrote:
> 
> 
>> On 22 Mar 2020, at 07:56, Frank Millman <frank at chagford.com> wrote:
>>
>> On 2020-03-21 8:04 PM, Barry Scott wrote:
>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>
>> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!
> 
> You can tell wireshark to only capture on one interface and to only capture packets for port 80.
> (Captureing HTTPS means you cannot decode the packets without going deeper I recall)
> 
> Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.
> 

Thanks. I am more or less doing that. Interestingly the [RST,ACK] 
messages appear on the tcp packets, so if I filter on http I do not see 
them.

> 
>>
>> One thing immediately stands out. When I run it with MS Edge and Python3.8, it shows a lot of lines highlighted in red, with the symbols [RST,ACK]. They do not appear when running Chrome, and they do not appear when running Python3.7.
> 
> As Chris said that should not happen.
> 

As I replied to Chris, they appear in packets sent *from* Python *to* Edge.

>>
>> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.
> 
> What is the async wait to wait for the transmit buffers to drain?
> 

Not sure what you are asking. I am just doing what it says in the docs -

=================

write(data)
The method attempts to write the data to the underlying socket 
immediately. If that fails, the data is queued in an internal write 
buffer until it can be sent.

The method should be used along with the drain() method:

stream.write(data)
await stream.drain()

=================

coroutine drain()
Wait until it is appropriate to resume writing to the stream. Example:

writer.write(data)
await writer.drain()
This is a flow control method that interacts with the underlying IO 
write buffer. When the size of the buffer reaches the high watermark, 
drain() blocks until the size of the buffer is drained down to the low 
watermark and writing can be resumed. When there is nothing to wait for, 
the drain() returns immediately.

=================

Frank


More information about the Python-list mailing list