From 9a1eb5bf0be001d475f7018fa5efa7598a73ff66 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Oct 2025 00:44:31 +0000 Subject: [PATCH] Remove lock checking and setting from event step, keep only deletion in finally --- .../advoware_cal_sync/calendar_sync_event_step.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py index c4fc4aed..307d771f 100644 --- a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py +++ b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py @@ -848,9 +848,9 @@ async def process_updates(state, conn, service, calendar_id, kuerzel, advoware, await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id']) CALENDAR_SYNC_LOCK_KEY = 'calendar_sync_lock' -async def handler(context): +async def handler(event_data, context): """Main event handler for calendar sync.""" - kuerzel = context.input.data.get('kuerzel') + kuerzel = event_data.get('kuerzel') if not kuerzel: log_operation('error', "No kuerzel provided in event", context=context) return {'status': 400, 'body': {'error': 'No kuerzel provided'}} @@ -867,13 +867,6 @@ async def handler(context): ) try: - if redis_client.get(employee_lock_key): - log_operation('info', f"Sync already running for {kuerzel}, skipping", context=context) - return {'status': 200, 'body': {'status': 'skipped', 'reason': 'sync_already_running', 'kuerzel': kuerzel}} - - # Set lock for 30 minutes - redis_client.set(employee_lock_key, 'event', ex=1800) - log_operation('info', f"Lock set for {kuerzel}, starting sync", context=context) log_operation('debug', "Initializing Advoware API", context=context) advoware = AdvowareAPI(context)