mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
work around python not handling non-latin hostname
https://anki.tenderapp.com/discussions/beta-testing/763-anki-does-not-seem-to-start-on-windows-10
This commit is contained in:
parent
8fe766c750
commit
1842db2a8f
1 changed files with 13 additions and 1 deletions
|
@ -6,7 +6,7 @@ from aqt.qt import *
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import http.server
|
import http.server
|
||||||
import socketserver
|
import socketserver
|
||||||
import errno
|
import socket
|
||||||
from anki.utils import devMode
|
from anki.utils import devMode
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
@ -28,8 +28,20 @@ _exportFolder = _getExportFolder()
|
||||||
# webengine on windows sometimes opens a connection and fails to send a request,
|
# webengine on windows sometimes opens a connection and fails to send a request,
|
||||||
# which will hang the server if unthreaded
|
# which will hang the server if unthreaded
|
||||||
class ThreadedHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
|
class ThreadedHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
|
||||||
|
# allow for a flood of requests before we've started up properly
|
||||||
request_queue_size = 100
|
request_queue_size = 100
|
||||||
|
|
||||||
|
# work around python not being able to handle non-latin hostnames
|
||||||
|
def server_bind(self):
|
||||||
|
"""Override server_bind to store the server name."""
|
||||||
|
socketserver.TCPServer.server_bind(self)
|
||||||
|
host, port = self.server_address[:2]
|
||||||
|
try:
|
||||||
|
self.server_name = socket.getfqdn(host)
|
||||||
|
except:
|
||||||
|
self.server_name = "server"
|
||||||
|
self.server_port = port
|
||||||
|
|
||||||
class MediaServer(threading.Thread):
|
class MediaServer(threading.Thread):
|
||||||
|
|
||||||
_port = None
|
_port = None
|
||||||
|
|
Loading…
Reference in a new issue