Fixing possible race in task_base