Run urlcleanup() before running urlopen()

This commit is contained in:
Kumi 2022-02-23 06:45:27 +01:00
parent 8407e980cb
commit 96562f6298

View file

@ -1,5 +1,5 @@
from http.server import BaseHTTPRequestHandler
from urllib.request import urlopen
from urllib.request import urlopen, urlcleanup
from urllib.error import URLError
from socket import error, timeout
from io import BytesIO
@ -17,6 +17,7 @@ class ImageHandler(BaseHTTPRequestHandler):
def get_next_image(self):
try:
bfr = BytesIO()
urlcleanup()
src = urlopen(self.source_image).read()
bfr.write(src)
bfr.seek(0)