fix tasks dictionary changed size during iteration when reload tasks