# Note: check_same_thread=False is OK as the implementation uses a lock