I am trying to build a web app on Google App Engine (GAE) using python and Flask. I want to know how to call a function within the app multiple times simultaneously. For example, I have a function which returns the square of an element. Now, I wrap this function under a URL like this:
@app.route('/single_number',methods = ['GET','POST'])
def square():
x = request.form.get('input_number')
return x*x
Now, I want to do this on a list of numbers but concurrently on 'http://localhost:8080/list_of_numbers'. Say, I have a list of 'n' numbers and I want to calculate the square of each number simultaneously (if not all 'n' together but at least what Google App Engine allows). I have used multiprocessing library of Python but got no performance improvement because of the single core used in Google App Engine instance and apparently, multithreading is equally futile. So, upon reading some more I was led to Cloud Tasks of GAE. But I am not able to wrap my head around executing this on Cloud Tasks. Any sample/tutorial related to this will be greatly appreciated. If you think that Cloud Tasks is not the right way for this problem, is it possible to create a function under handler '/list_of_numbers', which will send multiple numbers of the list to the '/single_number' handler simultaneously? Or do you suggest any other method?
I am new to web-app building and GAE. So, any help would be greatly appreciated.
Thanks in advance