dclandau commented on PR #25469:
URL: https://github.com/apache/airflow/pull/25469#issuecomment-1203291083

   The tests were failing because when writing bytes into the file, python 
buffers the data until it is flushed via the method `fp.flush()`.
   Because the file was not being flushed prior to the if statement, 
`os.stat(fp.name).st_size` was only indicating the size of the file as is in 
the system, without including the bytes still to be flushed.
   
   As a quick sanity test you can run:
   ```python
   with open('test', 'wb') as f:
       f.write(b'hello')
       print(f.tell())
       import os
       print(os.stat(f.name).st_size)
       f.seek(0, os.SEEK_END)
       print(f.tell())
       f.flush()
       print(os.stat(f.name).st_size)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to