[Python] Django background task not runnng

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to send an email with a Django background task. But the problem is that when I run python manage.py process_tasks nothing happens. I am just stuck in part where it looks like it is running but nothing is returned to the terminal. There was a few times where in fact it did run but it took very long.

    logger = logging.getLogger(__name__)


    @background(schedule=1)
    def notify_user():
    logger.info("Task started")
    smtp_server = "smtp.gmail.com"
    port = 465

    sender = "email"
    password = "password"

    context = ssl.create_default_context()

    with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
    server.login(sender, password)
    print("Yes")
    user = get_user_model()


    I have tried changing the intervals in between runs to 60(seconds) but it wasn't working so I changed it to 1(second) to see if it would work. But alas it doesn't

    Continue reading...

Compartilhe esta Página