code: def _add_monitor(monitors, handle, callback, devices, events):
      
  
      for conn_string in devices:
          data = monitors.get(conn_string)
          if data is None:
              data = dict()
              monitors[conn_string] = data
  
          for event in events:
              event_dict = data.get(event)
              if event_dict is None:
                  event_dict = dict()
                  data[event] = event_dict
  
              event_dict[handle] = callback
docs: Add the given monitor to the listed devices and events.