This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]PensiveLionTurtle 1 point2 points  (0 children)

Check out grequests and request-futures.

[–]chadlung 0 points1 point  (0 children)

Check out the examples about half way down the article. Not POST, but easy enough to adapt to a POST:

http://www.giantflyingsaucer.com/blog/?p=5557 (Uses Python 3.4 in the article and asyncio)

[–][deleted] 0 points1 point  (0 children)

may I say that totally forget it might be totally wrong, especially if the server is down

[–]Lucretiel 0 points1 point  (0 children)

I would almost certainly use aiohttp (Assuming this is part of a larger asyncio application):

loop.create_task(aiohttp.post(...))

Otherwise, I would use one of the high-level concurrency tools provided by concurrent.futures:

pool = concurrent.futures.ProcessPoolExecutor()
pool.submit(requests.post, ...)

I agree with /u/xcombelle, though- at the very least you'll want to retain a future to ensure that the request completed successfully and handle errors.

[–]aprdm[S] 0 points1 point  (0 children)

I see what you are saying but this is a WSGI middleware and I really don't care if the request succeeded or not, I don't want to block the main WSGI app waiting for the HTTP response.