You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using aiohttp under WSL as a dependency of maubot. I always get an error "ValueError: I/O operation on closed file" when attempting to upload a file.
To Reproduce
When running Maubot's mbc upload function from a WSL host box, the following error appears:
Fatal error running command
Traceback (most recent call last):
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/maubot/cli/cliq/cliq.py", line 99, in wrapper
asyncio.run(res)
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/maubot/cli/cliq/cliq.py", line 55, in wrapper
return await func(*args, sess=sess, server=server, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/maubot/cli/commands/upload.py", line 37, in upload
await upload_file(sess, file, server)
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/maubot/cli/commands/upload.py", line 43, in upload_file
async with sess.post(url, data=file, headers=headers) as resp:
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/aiohttp/client.py", line 1194, in __aenter__
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/aiohttp/client.py", line 545, in _request
req = self._request_class(
^^^^^^^^^^^^^^^^^^^^
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 334, in __init__
self.update_body_from_data(data)
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 559, in update_body_from_data
size = body.size
^^^^^^^^^
File "/home/user/src/matrix/maubot/lib/python3.11/site-packages/aiohttp/payload.py", line 377, in size
return os.fstat(self._value.fileno()).st_size - self._value.tell()
^^^^^^^^^^^^^^^^^^^^
ValueError: I/O operation on closed file
The following patch eliminates the error and everything then works fine:
I haven't dug into this much but it seems like os.fstat is returning an error that aiohttp doesn't expect when run from a WSL device. Could you broaden the except clause to at least include ValueError? Or is there some other more fundamental fix needed in Python's os library?
Expected behavior
aiohttp should fail gracefully
Logs/tracebacks
See error message in problem description.
Python Version
Python 3.11.4
aiohttp Version
Version: 3.9.5
multidict Version
Version: 6.0.5
yarl Version
Version: 1.9.4
OS
Windows Subsystem for Linux (WSL)
Related component
Client
Additional context
N/A
Code of Conduct
I agree to follow the aio-libs Code of Conduct
The text was updated successfully, but these errors were encountered:
Describe the bug
Using aiohttp under WSL as a dependency of maubot. I always get an error "ValueError: I/O operation on closed file" when attempting to upload a file.
To Reproduce
When running Maubot's
mbc upload
function from a WSL host box, the following error appears:The following patch eliminates the error and everything then works fine:
I haven't dug into this much but it seems like
os.fstat
is returning an error that aiohttp doesn't expect when run from a WSL device. Could you broaden theexcept
clause to at least include ValueError? Or is there some other more fundamental fix needed in Python'sos
library?Expected behavior
aiohttp should fail gracefully
Logs/tracebacks
Python Version
Python 3.11.4
aiohttp Version
Version: 3.9.5
multidict Version
Version: 6.0.5
yarl Version
Version: 1.9.4
OS
Windows Subsystem for Linux (WSL)
Related component
Client
Additional context
N/A
Code of Conduct
The text was updated successfully, but these errors were encountered: