Fixing #1026: Lock in thread_queue was held while performing a possibly suspending function