Skip to content

Commit a75aea1

Browse files
committed
mavproxy_firmware.py: fix race condition around downloaders
1 parent ceafe35 commit a75aea1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Diff for: MAVProxy/modules/mavproxy_firmware.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,14 @@ def download_firmware(self, firmware, filename=None):
279279
print("Download timeout")
280280
if not child.is_alive():
281281
break
282-
print("Waiting for download to compliete...")
282+
print("Waiting for download to complete...")
283283
time.sleep(1)
284284

285285
return filename
286286

287287
def fw_manifest_usage(self):
288288
'''return help on manifest subcommand'''
289-
return("Usage: fw manifest <list|download|purge>")
289+
return("Usage: fw manifest <list|download|purge|status>")
290290

291291
def cmd_fw_manifest_help(self):
292292
'''show help on manifest subcommand'''
@@ -330,6 +330,8 @@ def cmd_fw_manifest(self, args):
330330
return self.manifest_download()
331331
if args[0] == "list":
332332
return self.cmd_fw_manifest_list()
333+
if args[0] == "status":
334+
return self.cmd_fw_manifest_status()
333335
if args[0] == "load":
334336
return self.cmd_fw_manifest_load()
335337
if args[0] == "purge":
@@ -367,14 +369,19 @@ def manifests_parse(self):
367369
continue
368370
self.manifests.append(manifest)
369371

372+
def cmd_fw_manifest_status(self):
373+
'''brief summary of manifest status'''
374+
print(f"fw: {len(list(self.downloaders.keys()))} downloaders")
375+
print(f"fw: {len(self.find_manifests())} manifests")
376+
370377
def download_url(self, url, path):
371378
mp_util.download_files([(url,path)])
372379

373380
def idle_task(self):
374381
'''called rapidly by mavproxy'''
375382
if self.downloaders_lock.acquire(False):
376383
removed_one = False
377-
for url in self.downloaders.keys():
384+
for url in list(self.downloaders.keys()):
378385
if not self.downloaders[url].is_alive():
379386
print("fw: Download thread for (%s) done" % url)
380387
del self.downloaders[url]

0 commit comments

Comments
 (0)