Pythonify locking in SocketConnection