**Describe the bug** Error happens when the preprocesssing/inversing workload is large and thread dataloader is used. The issue is found by @wyli