fix: remove task on post_delete instead of pre_delete to handle possible deletion errors. import signal.

This commit is contained in:
Jan Koppe 2020-05-31 18:34:51 +02:00
parent e1943b05f4
commit cf6373c7cb
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from django.dispatch import receiver from django.dispatch import receiver
from django.db.models.signals import post_save from django.db.models.signals import post_save, post_delete
from rtmp.signals import stream_active from rtmp.signals import stream_active
from .models import RestreamConfig from .models import RestreamConfig
from rtmp.models import Stream from rtmp.models import Stream
@ -35,7 +35,7 @@ def update_tasks(sender, **kwargs):
task.save() task.save()
@receiver(pre_delete, sender=RestreamConfig) @receiver(post_delete, sender=RestreamConfig)
def delete_tasks(sender, **kwargs): def delete_tasks(sender, **kwargs):
instance = kwargs['instance'] instance = kwargs['instance']
# Get the current task instance if it exists, and remove it # Get the current task instance if it exists, and remove it