python: Fix callback dispatch stopping on disconnect

Callback could still get dispatched while the socket was already closed.
This results in a guaranteed timeout exception for getters calls from
callback functions.

Use an additional lock to serialize disconnect and callback dispatch.
python: Fix race condition in socket closing on socket receive error

Avoid closing the wrong socket, if the disconnect callback is delayed
and a new socket has been opened in the meantime.
python: Handle socket error on send