refresh_links_for_backend: handling KeyboardInterrupt better
It now reports on the number of refreshed links before aborting.
This commit is contained in:
parent
fbf7dd9596
commit
1312ededfb
@ -474,6 +474,7 @@ def refresh_links_for_backend(backend_name, chunk_size, expiry_seconds):
|
||||
|
||||
refreshed = 0
|
||||
for file_doc in to_refresh:
|
||||
try:
|
||||
file_id = file_doc['_id']
|
||||
project_id = file_doc.get('project')
|
||||
if project_id is None:
|
||||
@ -501,8 +502,11 @@ def refresh_links_for_backend(backend_name, chunk_size, expiry_seconds):
|
||||
log.warning('Skipping file %s, GCS forbids us access to project %s bucket.',
|
||||
file_id, project_id)
|
||||
continue
|
||||
|
||||
refreshed += 1
|
||||
except KeyboardInterrupt:
|
||||
log.warning('Aborting due to KeyboardInterrupt after refreshing %i links',
|
||||
refreshed)
|
||||
return
|
||||
|
||||
log.info('Refreshed %i links', refreshed)
|
||||
|
||||
|
@ -593,10 +593,7 @@ def refresh_backend_links(backend_name, chunk_size=50, quiet=False, window=12):
|
||||
chunk_size = int(chunk_size) # CLI parameters are passed as strings
|
||||
from application.modules import file_storage
|
||||
|
||||
try:
|
||||
file_storage.refresh_links_for_backend(backend_name, chunk_size, window * 3600)
|
||||
except KeyboardInterrupt:
|
||||
print('Aborted due to keyboard interrupt.')
|
||||
|
||||
|
||||
@manager.command
|
||||
|
Loading…
x
Reference in New Issue
Block a user