Skip to content

Commit 099d26c

Browse files
committed
improve sync error handling
1 parent 753e20c commit 099d26c

2 files changed

Lines changed: 34 additions & 26 deletions

File tree

api.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -302,31 +302,35 @@ async def discord_sync_update(message, done=False):
302302

303303
async def discord_sync():
304304
start_time = time.time()
305-
await discord_sync_update('moving level channels to categories')
306-
await discord_utils.move_all_levels_to_categories()
307-
await discord_sync_update('updating role permissions')
308-
last_update = time.time()
309-
async for progress in discord_utils.update_role_permissions():
310-
if time.time() - last_update > 10:
311-
await discord_sync_update(f'{progress} role permissions updated')
312-
last_update = time.time()
313-
await asyncio.sleep(1)
314-
await discord_sync_update('updating user roles')
315-
last_update = time.time()
316-
async for progress in discord_utils.update_all_user_roles():
317-
if time.time() - last_update > 10:
318-
await discord_sync_update(f'{progress} user roles updated')
319-
last_update = time.time()
320-
await asyncio.sleep(1)
321-
await discord_sync_update('updating user nicknames')
322-
last_update = time.time()
323-
async for progress in discord_utils.update_all_user_nicknames():
324-
if time.time() - last_update > 10:
325-
await discord_sync_update(f'{progress} nicknames updated')
326-
last_update = time.time()
327-
await asyncio.sleep(1)
328-
used_time = time.time() - start_time
329-
await discord_sync_update(f'finished discord sync after {used_time:.2f}s', True)
305+
try:
306+
await discord_sync_update('moving level channels to categories')
307+
await discord_utils.move_all_levels_to_categories()
308+
await discord_sync_update('updating role permissions')
309+
last_update = time.time()
310+
async for progress in discord_utils.update_role_permissions():
311+
if time.time() - last_update > 10:
312+
await discord_sync_update(f'{progress} role permissions updated')
313+
last_update = time.time()
314+
await asyncio.sleep(1)
315+
await discord_sync_update('updating user roles')
316+
last_update = time.time()
317+
async for progress in discord_utils.update_all_user_roles():
318+
if time.time() - last_update > 10:
319+
await discord_sync_update(f'{progress} user roles updated')
320+
last_update = time.time()
321+
await asyncio.sleep(1)
322+
await discord_sync_update('updating user nicknames')
323+
last_update = time.time()
324+
async for progress in discord_utils.update_all_user_nicknames():
325+
if time.time() - last_update > 10:
326+
await discord_sync_update(f'{progress} nicknames updated')
327+
last_update = time.time()
328+
await asyncio.sleep(1)
329+
used_time = time.time() - start_time
330+
await discord_sync_update(f'finished discord sync after {used_time:.2f}s', True)
331+
except Exception as e:
332+
await discord_sync_update(traceback.format_exc(), done=True)
333+
raise e
330334

331335

332336
@protected

entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
alembic upgrade head
44
python manage.py init
5-
python manage.py run --host 0.0.0.0 --port 80
5+
if [[ "$DEBUG" = "true" || "$DEBUG" = "1" ]]; then
6+
python manage.py run --host 0.0.0.0 --port 80 --debug
7+
else
8+
python manage.py run --host 0.0.0.0 --port 80
9+
fi

0 commit comments

Comments
 (0)