15

I tried the following:

import grequests

urls = ['http://localhost/test', 'http://localhost/test']

params = {'a':'b', 'c':'d'}
rs = (grequests.post(u, params) for u in urls)
grequests.map(rs)

But it says the following:

File "search.py", line 6, in <genexpr>
rs = (grequests.post(u, params) for u in urls)
TypeError: __init__() takes exactly 3 arguments (4 given)

I also need to pass the response to a callback for processing.

Crypto
  • 1,217
  • 3
  • 17
  • 33
  • Can you give the exact line number of the error message? I don't see anywhere in your code that you're calling something with 4 arguments. – jeffknupp Jan 12 '14 at 19:04
  • It is in line number 6. I have updated the question with the error message. – Crypto Jan 12 '14 at 19:06

1 Answers1

35

grequests.post() function takes only one positional argument i.e URL to which you have send that POST request. The rest of the parameters are taken as key word arguments.

So you need to call grequests.post() as:

import grequests

urls = ['http://localhost/test', 'http://localhost/test']

params = {'a':'b', 'c':'d'}
rs = (grequests.post(u, data=params) for u in urls)
grequests.map(rs)
praveen
  • 3,193
  • 2
  • 26
  • 30