code: def _get_mid_and_update_msg(self, msg, use_mid):
          
          if use_mid is None:
              use_mid = self._server_supports_ids
  
          if msg.mid is None:
              mid = self._next_id()
              if use_mid:
                  msg.mid = mid
              # An internal mid may be needed for the request/inform/response
              # machinery to work, so we return it
              return mid
          else:
              return msg.mid
docs: Get message ID for current request and assign to msg.mid if needed.
  
          Parameters
          ----------
          msg : katcp.Message ?request message
          use_mid : bool or None
  
          If msg.mid is None, a new message ID will be created. msg.mid will be
          filled with this ID if use_mid is True or if use_mid is None and the
          server supports message ids. If msg.mid is already assigned, it will
          not be touched, and will be used as the active message ID.
  
          Return value
          ------------
          The active message ID