code: def lock(self, session):
          
          if self.busy:
              raise ConnectionBusyError(self)
          with self._lock:
              self.used_by = weakref.ref(session)
          LOGGER.debug('Connection %s locked', self.id)
docs: Lock the connection, ensuring that it is not busy and storing
          a weakref for the session.
  
          :param queries.Session session: The session to lock the connection with
          :raises: ConnectionBusyError