From a815d36cd11e8c6caf5230ededd75427585436d5 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 16 Sep 2016 13:46:20 +0100 Subject: [PATCH] Little example of using Notifier.skip. --- fsl/utils/notifier.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fsl/utils/notifier.py b/fsl/utils/notifier.py index c9ff442c6..54d055ab1 100644 --- a/fsl/utils/notifier.py +++ b/fsl/utils/notifier.py @@ -189,6 +189,20 @@ class Notifier(object): def skip(self, name, topic=None): """Context manager which disables the speciifed listener, and restores its state before returning. + + You can use this method if you have some code which triggers a + notification, but you do not your own listener to be notified. + For example:: + + def __myListener(*a): + pass + + notifier.register('myListener', __myListener) + + with notifier.skip('myListener'): + # if a notification is triggered + # by the code here, the __myListener + # function will not be called. """ state = self.isEnabled(name, topic) -- GitLab