mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-05 01:43:16 +03:00
Try to send any unsent events on closing
This commit is contained in:
parent
80d1b0760c
commit
7d1fa33aa0
@ -269,18 +269,19 @@ def cmdr_data(data, is_beta):
|
|||||||
def worker():
|
def worker():
|
||||||
|
|
||||||
pending = [] # Unsent events
|
pending = [] # Unsent events
|
||||||
|
closing = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
item = this.queue.get()
|
item = this.queue.get()
|
||||||
if not item:
|
if item:
|
||||||
return # Closing
|
|
||||||
else:
|
|
||||||
(cmdr, entry) = item
|
(cmdr, entry) = item
|
||||||
|
else:
|
||||||
|
closing = True # Try to send any unsent events before we close
|
||||||
|
|
||||||
retrying = 0
|
retrying = 0
|
||||||
while retrying < 3:
|
while retrying < 3:
|
||||||
try:
|
try:
|
||||||
if entry['event'] not in this.discardedEvents:
|
if item and entry['event'] not in this.discardedEvents:
|
||||||
pending.append(entry)
|
pending.append(entry)
|
||||||
|
|
||||||
# Get list of events to discard
|
# Get list of events to discard
|
||||||
@ -309,7 +310,7 @@ def worker():
|
|||||||
if msgnum // 100 == 2:
|
if msgnum // 100 == 2:
|
||||||
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': '))))
|
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': '))))
|
||||||
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
|
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
|
||||||
else:
|
elif not closing:
|
||||||
# Update main window's system status
|
# Update main window's system status
|
||||||
for i in range(len(pending) - 1, -1, -1):
|
for i in range(len(pending) - 1, -1, -1):
|
||||||
if pending[i]['event'] in ['StartUp', 'Location', 'FSDJump']:
|
if pending[i]['event'] in ['StartUp', 'Location', 'FSDJump']:
|
||||||
@ -329,6 +330,9 @@ def worker():
|
|||||||
else:
|
else:
|
||||||
plug.show_error(_("Error: Can't connect to EDSM"))
|
plug.show_error(_("Error: Can't connect to EDSM"))
|
||||||
|
|
||||||
|
if closing:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
# Whether any of the entries should be sent immediately
|
# Whether any of the entries should be sent immediately
|
||||||
def should_send(entries):
|
def should_send(entries):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user