Closed ajkessel closed 2 months ago
@webknjaz Looks like the same error in your PR. https://github.com/aio-libs/aiohttp/actions/runs/8932413272/job/24536311770#step:11:6511
@Dreamsorcerer that seems to be happening in a different place, though..
@ajkessel What is the file variable in your traceback?
It appears the error actually comes from file.fileno()
, so I'll need to know what that object is.
Actually, looks like it may just be a regular file object:
>>> f = open("README.rst")
>>> f.fileno()
3
>>> f.close()
>>> f.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
But, I guess the question is why is it closed when in your code...
And how can catching that exception fix your application? If the file is closed, then the .read() call when you try to write the payload will also fail..
I'll need a some more info that helps answer some of that before deciding what should be changed here. Currently, I can't see how catching that exception would help.
This is several months old and I'm not able to replicate this currently. I'm not sure what's changed but I've been through multiple WSL and Ubuntu upgrades since I reported this bug. I suppose if no one else is seeing it, we could just close it, unless you want to be more forgiving about the types of exceptions that can be caught (or give the user more info when a filesystem exception is raised).
unless you want to be more forgiving about the types of exceptions that can be caught (or give the user more info when a filesystem exception is raised).
I'm just not clear what we could realistically change. Catching the error when the file is closed surely makes no difference as it will just fail again at the next step with the exact same error. We can't do anything useful with a closed file object.
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
aiohttp Version
multidict Version
yarl Version
OS
Windows Subsystem for Linux (WSL)
Related component
Client
Additional context
N/A
Code of Conduct