<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cancel(self):
 """Cancels the observer No more notifications will be passed on """

        LOG.debug('cancelling %s', self)
        self._cancelled = True
        self.clear_callbacks()  # not strictly necessary, but may release references
        while True:
            try:
                self._waitables.get_nowait().put_nowait(self.sentinel)
            except queue.Empty:
                break