<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_monitor(self, devices, events, callback):
 """Register a callback when events happen. If this method is called, it is guaranteed to take effect before the next call to ``_notify_event`` after this method returns. This method is safe to call from within a callback that is itself called by ``notify_event``. See :meth:`AbstractDeviceAdapter.register_monitor`. """


        # Ensure we don't exhaust any iterables
        events = list(events)
        devices = list(devices)

        for event in events:
            if event not in self.SUPPORTED_EVENTS:
                raise ArgumentError("Unknown event type {} specified".format(event), events=events)

        monitor_id = str(uuid.uuid4())

        action = (monitor_id, "add", devices, events)
        self._callbacks[monitor_id] = callback

        if self._currently_notifying:
            self._deferred_adjustments.append(action)
        else:
            self._adjust_monitor_internal(*action)

        return monitor_id