It seems like that the issue is caused by not awaiting the following asynchronous task:
# Create task for delayed context printing asyncio.create_task( print_contexts_after_delay(playwright_browser, task_id, downloaded_files) )