I decided to implement downloading files from the internet, but I met with the problem that when the internet disappears, downloading the package with this code: for data in self.file.iter_content(chunk_size=1024): goes into an endless waiting for a miracle, even the appearance of the internet does not revive this process.
I wanted to make a timeout, but the cycle ends completely without the ability to resume loading from the stop point. There was also an idea to write data to a variable during timeout in except and try to load packages not from the saved data to the end of iter_content, but I do not know how to do it.