Here is the situation. I need to send a ajax request to a Django view function every second and this view function will send some asynchronous requests to a third party API to get some data by grequests. These data will render to HTML after this view function returned. here show the code
desc_ip_list=['58.222.24.253', '58.222.17.38']
reqs = [grequests.get('%s%s' % ('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=', desc_ip))
for desc_ip in desc_ip_list]
response = grequests.map(reqs)
When I runserver django and send this ajax request, the amount of threads of python is always increasing until error "can't start new thread" happened. enter image description here
error: can't start new thread
<Greenlet at 0x110473b90: <bound method AsyncRequest.send of <grequests.AsyncRequest object at 0x1103fd1d0>>(stream=False)>
failed with error
How can I control the amount of threads? I have no idea of it because I'm a beginner pythoner. Thanks a lot.