Fix race in 'BackgroundConsumer._thread_main'. (#8883)

See #7817.
1 file changed