1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Added a way to check if a signal has listeners

This commit is contained in:
Anssi Kääriäinen
2012-09-20 03:18:19 +03:00
parent 07ffe78143
commit 3fcca0e947
2 changed files with 14 additions and 0 deletions

View File

@@ -141,6 +141,9 @@ class Signal(object):
del self.receivers[index]
break
def has_listeners(self, sender=None):
return bool(self._live_receivers(_make_id(sender)))
def send(self, sender, **named):
"""
Send signal from sender to all connected receivers.