Forums

Threading

Hi, I have deployed a django app on pythonanywhere. There's a step where I need to run a web automation after rendering a web page. I'm doing it with the help of threading available in python. It works just fine when I tried it on my local machine but it seems to not work on pythonanywhere. It just renders the page and the process seems to not execute. Basically it should send an email after the process has done executing in like 3-4 minutes (which it does when I run it on my machine) but it's not sending any email when I run it on here. I don't get any error messages either. Could you please help me there? The code goes like,

import threading
def fun(requests):
    t = threading.Thread(target = some_target_function, args = [arg1, arg2])
    t.start()
    return render(request, 'page.html', context=context)

That would not work inside the web app on PythonAnywhere. You can do threading in scheduled and always-on tasks.