@contextmanager
def disconnected_from_listeners(signal):
 listeners = list(signal.receivers_for(ANY))
 for listener in listeners:
  signal.disconnect(listener)
 (yield)
 for listener in listeners:
  signal.connect(listener)

@ contextmanager def disconnected_from_listeners ( signal ) : listeners = list ( signal . receivers_for ( ANY ) ) for listener in listeners : signal . disconnect ( listener ) ( yield ) for listener in listeners : signal . connect ( listener )
temporarily disconnect all listeners for a blinker signal .