\Anaconda3\lib\tempfile.py", line 483, in func_wrapper return func(*args, **kwargs) ValueError: read of closed file
I don't know if this is the issue even I can't figure this out. This is being called in a loop and the first loops works fine but errors on the second loop. Reading the file it says
"This class provides a wrapper around files opened for temporary use. In particular, it seeks to automatically remove the file when it is no longer needed."
But it is still needed and closing anyway, causing the error. This is my best guess.
I'm using this because a normal request is blocked by the server. Which by the way, a normal request loops and works fine (tested unblocked links). This one works on the first cycle then fails on the second. I think because the "link" variable is being reused.
class AppURLopener(urllib.request.FancyURLopener):
version = "Mozilla/5.0"
looping part
opener = AppURLopener()
linkSource = opener.open(link).read() #error on this line "read of closed file (second run through)"
I tried to modify the code so that the "link" variable is different which I'm guessing would solve it but the only way I could find to do that was make it a list or a dictionary. Both of those don't work because the base variable is still closed I guess.
In that case I tried using open() at the start of the loop which produces an error like this "TypeError: expected str, bytes or os.PathLike object, not dict"
If I just have it be a normal string it doesn't work either which on another point doesn't make sense because above it says "expected str", I assumed if it was just a normal str it would work but it just produces another error "OSError: [Errno 22] Invalid argument: http://www.link.com"
I guess random variables can't be used with open() like that. So why is it closed? Or is something else closed?
I don't know.