bugfix: we must wait for the callbacks because they may be dispatched in a separate Python thread, which may not be completed immediately