Run urlcleanup() before running urlopen()
This commit is contained in:
parent
8407e980cb
commit
96562f6298
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
from http.server import BaseHTTPRequestHandler
|
from http.server import BaseHTTPRequestHandler
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen, urlcleanup
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
from socket import error, timeout
|
from socket import error, timeout
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
@ -17,6 +17,7 @@ class ImageHandler(BaseHTTPRequestHandler):
|
||||||
def get_next_image(self):
|
def get_next_image(self):
|
||||||
try:
|
try:
|
||||||
bfr = BytesIO()
|
bfr = BytesIO()
|
||||||
|
urlcleanup()
|
||||||
src = urlopen(self.source_image).read()
|
src = urlopen(self.source_image).read()
|
||||||
bfr.write(src)
|
bfr.write(src)
|
||||||
bfr.seek(0)
|
bfr.seek(0)
|
||||||
|
|
Loading…
Reference in a new issue