Retry sending message after a sleep

Avoids spurious errors on multiple simultaneous calibre launches. Fixes #1927546 ["ERROR: Contacting calibre failed"](https://bugs.launchpad.net/calibre/+bug/1927546)
This commit is contained in:
Kovid Goyal 2021-05-07 07:22:51 +05:30
parent dc88a74caa
commit 88ba140db9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -447,14 +447,18 @@ singleinstance_name = 'GUI'
def send_message(msg): def send_message(msg):
try: try:
send_message_in_process(msg) send_message_in_process(msg)
except Exception as err: except Exception:
print(_('Failed to contact running instance of calibre'), file=sys.stderr, flush=True) time.sleep(2)
print(err, file=sys.stderr, flush=True) try:
if Application.instance(): send_message_in_process(msg)
error_dialog(None, _('Contacting calibre failed'), _( except Exception as err:
'Failed to contact running instance of calibre, try restarting calibre'), print(_('Failed to contact running instance of calibre'), file=sys.stderr, flush=True)
det_msg=str(err) + '\n\n' + repr(msg), show=True) print(err, file=sys.stderr, flush=True)
return False if Application.instance():
error_dialog(None, _('Contacting calibre failed'), _(
'Failed to contact running instance of calibre, try restarting calibre'),
det_msg=str(err) + '\n\n' + repr(msg), show=True)
return False
return True return True