work around existing instance not responding quickly

on a slow computer the first instance may have set up the local
server but not yet started the main loop, so when a user double clicks
on the icon twice, the second instance was timing out and opening
another window, then giving locked database errors

to work around this, increase the timeout, and tell the user the
existing instance is not responding instead of creating a new instance

https://anki.tenderapp.com/discussions/ankidesktop/30306-error
https://anki.tenderapp.com/discussions/ankidesktop/30550-im-sorry
This commit is contained in:
Damien Elmes 2018-10-28 14:17:16 +10:00
parent 2483e9c89e
commit e18bd4d67d

View file

@ -157,7 +157,7 @@ class AnkiApp(QApplication):
appMsg = pyqtSignal(str) appMsg = pyqtSignal(str)
KEY = "anki"+checksum(getpass.getuser()) KEY = "anki"+checksum(getpass.getuser())
TMOUT = 5000 TMOUT = 30000
def __init__(self, argv): def __init__(self, argv):
QApplication.__init__(self, argv) QApplication.__init__(self, argv)
@ -191,7 +191,10 @@ class AnkiApp(QApplication):
sock.write(txt.encode("utf8")) sock.write(txt.encode("utf8"))
if not sock.waitForBytesWritten(self.TMOUT): if not sock.waitForBytesWritten(self.TMOUT):
# existing instance running but hung # existing instance running but hung
return False QMessageBox.warning(None, "Anki Already Running",
"If the existing instance of Anki is not responding, please close it using your task manager, or restart your computer.")
sys.exit(1)
sock.disconnectFromServer() sock.disconnectFromServer()
return True return True