mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 00:27:13 -05: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):
|
class MediaServer(QThread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.port = 8080
|
self.port = 10000
|
||||||
self.server = None
|
self.server = None
|
||||||
while not self.server:
|
while not self.server:
|
||||||
try:
|
try:
|
||||||
|
|
@ -26,6 +26,22 @@ class MediaServer(QThread):
|
||||||
|
|
||||||
class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
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):
|
def send_head(self):
|
||||||
path = self.translate_path(self.path)
|
path = self.translate_path(self.path)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue