I work with grequests in 3 pythons. Causes a TypeError error TypeError: 'AsyncRequest' object is not iterable . Code:

 import grequests u = 'http://shost-craft.su' params = {'a':'b', 'c':'d'} rs = grequests.post(u, data=params) responses_list = grequests.map(rs) print(responses_list[0].text) print(rs) 

I do not know why it is, it seems everything is correct. You can post method, get the same thing.

  • one
    ALWAYS lay out a FULL traceback exception. - Andrio Skur

1 answer 1

grequests.map designed for concurrent processing of several requests and receiving their responses, therefore, you are given an error stating that this method is applied to the object being iterated. To make your code work, you can wrap rs , for example, in the list:

 import grequests u = 'http://shost-craft.su' params = {'a':'b', 'c':'d'} rs = grequests.post(u, data=params) responses_list = grequests.map([rs]) print(responses_list[0].text) print(rs) 
  • Thank you so much) - you have no pass