mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
swallow http server errors
This commit is contained in:
parent
00111e4182
commit
53f7457d4c
1 changed files with 17 additions and 1 deletions
|
@ -10,7 +10,7 @@ import errno
|
|||
class MediaServer(QThread):
|
||||
|
||||
def run(self):
|
||||
self.port = 8080
|
||||
self.port = 10000
|
||||
self.server = None
|
||||
while not self.server:
|
||||
try:
|
||||
|
@ -26,6 +26,22 @@ class MediaServer(QThread):
|
|||
|
||||
class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
|
||||
def do_GET(self):
|
||||
f = self.send_head()
|
||||
if f:
|
||||
try:
|
||||
self.copyfile(f, self.wfile)
|
||||
except Exception as e:
|
||||
if os.getenv("ANKIDEV"):
|
||||
print("http server caught exception:", e)
|
||||
else:
|
||||
# swallow it - user likely surfed away from
|
||||
# review screen before an image had finished
|
||||
# downloading
|
||||
pass
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def send_head(self):
|
||||
path = self.translate_path(self.path)
|
||||
if os.path.isdir(path):
|
||||
|
|
Loading…
Reference in a new issue