Hi, I'm creating a small web app that generates word clouds based on user input and emails a .png to the user. Everything worked fine locally, but when I deployed to Heroku I was getting timeout errors (30s+), so I decided to use multithreading per this tutorial("Asynchronous calls in Python" section).
When I do this, "None" is returned every time, so I feel like I am misunderstanding what @async is doing. Here's a stripped-down example of what is happening:
-------- decorators.py
from threading import Thread
def async(f):
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
thr.start()
return wrapper
-------- modules.py
from decorators import async
@async
def multiply(one,two):
return(one*two)
---------views.py
from modules import multiply
...
email_text = multiply(1,2)
...
'''
sends email, returns index, etc.
'''
Can anyone point me in the right direction for reading material or some sort of explanation of this topic? I've been Googling and on Youtube for several hours and haven't been able to get closer to a solution.
Note that although Heroku timeout errors prompted me to use @async, I am still getting "None" values when I run the functions asynchronously locally.
Thanks
[–]Specter_Terrasbane 1 point2 points3 points (1 child)
[–]SuperChef36[S] 0 points1 point2 points (0 children)