I have 3 signal functions and one is getting stuck in a loop when it is called. It is called when an object inside of a model class is updated on the Django Admin page...
# models.py
class Item(models.Model):
...
foo = models.BooleanField(
default=False,
editable=True,
blank=True,
help_text='Blah Blah...'
)
# signals.py
@receiver(pre_save, sender=Item)
def foobar(sender, instance, **kwargs):
try:
pass
except:
pass
I literally put pass
in each try
and except
with a call to a log just to see if it is repeating even without code in them, and it is. Constantly with no end. This happens using an if / else
statement, too, instead of try / except
.
How the heck can I stop the signal from getting stuck in a loop? It is supposed to send an email each time, but now when the object is updated, the user gets blasted with infinite emails until I reboot Django.
I am really at a loss here...
BTW, this doesn't happen on my test server, only on my live/staging server.
EDIT:
If you are viewing this in the future, this is how I debugged my issue.
Look for anything that is running/hitting your server and potentially sparking a signal
to run. For me, it was a specific object that was set as the sender
for a signal to run, and each time the webhook I was using was causing a function to run, which was modifying the specific sender object
.