From Dev.to
Release a BytesIO Buffer View Before Resizing or Closing Its Stream
A buffer view and a byte snapshot have different lifetimes. Code that keeps a view of an in-memory stream may still read or modify its bytes, but the stream cannot be resized or closed while that view...
