add scheduled_work check in wait_for_task_or_scale to account for retry and scheduled queues