I wrote a python script that downloads files from the internet. However everytime I run the script, it seems like my computer is frozen.
Codes:
response = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in response.iter_content(chunk_size=2048):
if chunk:
f.write(chunk)
f.flush()
What can I do to this to load so my computer doesn't freeze?
Should I allocate a limited amount of ram? Or should I create a thread to do this?
Any advice would be appreciated. ty.