1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-19 02:17:38 +03:00

Try to send any unsent events on closing

This commit is contained in:
Jonathan Harris 2018-01-27 17:48:36 +00:00
parent 80d1b0760c
commit 7d1fa33aa0

View File

@ -269,18 +269,19 @@ def cmdr_data(data, is_beta):
def worker():
pending = [] # Unsent events
closing = False
while True:
item = this.queue.get()
if not item:
return # Closing
else:
if item:
(cmdr, entry) = item
else:
closing = True # Try to send any unsent events before we close
retrying = 0
while retrying < 3:
try:
if entry['event'] not in this.discardedEvents:
if item and entry['event'] not in this.discardedEvents:
pending.append(entry)
# Get list of events to discard
@ -309,7 +310,7 @@ def worker():
if msgnum // 100 == 2:
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': '))))
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
else:
elif not closing:
# Update main window's system status
for i in range(len(pending) - 1, -1, -1):
if pending[i]['event'] in ['StartUp', 'Location', 'FSDJump']:
@ -329,6 +330,9 @@ def worker():
else:
plug.show_error(_("Error: Can't connect to EDSM"))
if closing:
return
# Whether any of the entries should be sent immediately
def should_send(entries):