original_docstring: 
          Create an MQTT monitor.
          Messages are encapsulated in `MQTTmsg` objects.
  
          By default a monitor will only monitor a single entry. You may use
          MQTT wildcards.
  
          The message is decoded and stored in the ``value`` attribute unless
          it's either undecodeable or ``raw`` is set, in which case it's
          stored in ``.msg``. The topic the message was sent to is in
          ``topic``.
          
docstring: Create an MQTT monitor.
  Messages are encapsulated in `MQTTmsg` objects.
  
  By default a monitor will only monitor a single entry. You may use
  MQTT wildcards.
  
  
docstring_tokens: Create an MQTT monitor . Messages are encapsulated in ` MQTTmsg ` objects . By default a monitor will only monitor a single entry . You may use MQTT wildcards .
code: async def monitor(self, path, cls=MQTTmsg, **kw):
          """
          Create an MQTT monitor.
          Messages are encapsulated in `MQTTmsg` objects.
  
          By default a monitor will only monitor a single entry. You may use
          MQTT wildcards.
  
          The message is decoded and stored in the ``value`` attribute unless
          it's either undecodeable or ``raw`` is set, in which case it's
          stored in ``.msg``. The topic the message was sent to is in
          ``topic``.
          """
  
          class Monitor:
              """Helper class for reading an MQTT topic"""
  
              def __init__(self, admin, runner, client, cls, path, kw):
                  self.admin = admin
                  self.runner = runner
                  self.client = client
                  self.path = path
                  self.kw = kw
                  self.cls = cls
                  self.scope = None
  
              async def run(self):
                  with anyio.CancelScope() as sc:
                      self.scope = sc
                      async with self.client.msg_monitor(path, **kw) as watcher:
                          async for msg in watcher:
                              if "topic" in msg:
                                  # pylint:disable=attribute-defined-outside-init
                                  chg = cls(msg.get("raw", None))
                                  try:
                                      chg.value = msg.data
                                  except AttributeError:
                                      pass
                                  chg.path = Path.build(msg.topic)
                                  await self.runner.send_event(chg)
  
              async def cancel(self):
                  if self.scope is None:
                      return False
                  sc, self.scope = self.scope, None
                  sc.cancel()
  
          if isinstance(path, (tuple, list)):
              path = Path.build(path)
          elif not isinstance(path, Path):
              raise RuntimeError(f"You didn't pass in a path: {path!r}")
  
          w = Monitor(self, self._runner, self._client, cls, path, kw)
          self._taskgroup.spawn(w.run)
          return w
code_tokens: async def monitor ( self , path , cls = MQTTmsg , ** kw ) : class Monitor : """Helper class for reading an MQTT topic""" def __init__ ( self , admin , runner , client , cls , path , kw ) : self . admin = admin self . runner = runner self . client = client self . path = path self . kw = kw self . cls = cls self . scope = None async def run ( self ) : with anyio . CancelScope ( ) as sc : self . scope = sc async with self . client . msg_monitor ( path , ** kw ) as watcher : async for msg in watcher : if "topic" in msg : chg = cls ( msg . get ( "raw" , None ) ) try : chg . value = msg . data except AttributeError : pass chg . path = Path . build ( msg . topic ) await self . runner . send_event ( chg ) async def cancel ( self ) : if self . scope is None : return False sc , self . scope = self . scope , None sc . cancel ( ) if isinstance ( path , ( tuple , list ) ) : path = Path . build ( path ) elif not isinstance ( path , Path ) : raise RuntimeError ( f"You didn't pass in a path: {path!r}" ) w = Monitor ( self , self . _runner , self . _client , cls , path , kw ) self . _taskgroup . spawn ( w . run ) return w
short_docstring: Create an MQTT monitor.
short_docstring_tokens: Create an MQTT monitor .
comment: """
          Create an MQTT monitor.
          Messages are encapsulated in `MQTTmsg` objects.
  
          By default a monitor will only monitor a single entry. You may use
          MQTT wildcards.
  
          The message is decoded and stored in the ``value`` attribute unless
          it's either undecodeable or ``raw`` is set, in which case it's
          stored in ``.msg``. The topic the message was sent to is in
          ``topic``.
          """$SEP$"""Helper class for reading an MQTT topic"""$SEP$# pylint:disable=attribute-defined-outside-init