2

I have a raspberry module in which python code running. Now I have to call web services asynchronously from it. But when i write code and execute gives an error like

    Traceback (most recent call last):
  File "async_ws.py", line 3, in <module>
    from requests import async
ImportError: cannot import name async

my code is like

import json
import requests
from requests import async

urls = [
    'http://python-requests.org',
    'http://httpbin.org',
    'http://python-guide.org',
    'http://kennethreitz.com'
]

rs = [async.get(u) for u in urls]
async.map(rs)

pls help me

user3436441
  • 21
  • 1
  • 2
  • 1
    possible duplicate of [Asynchronous Requests with Python requests](http://stackoverflow.com/questions/9110593/asynchronous-requests-with-python-requests) – jfs Mar 26 '14 at 12:16

1 Answers1

1

That doesn't look like either of the most common async libraries for python requests, which are grequests (using gevent) and requests-futures. I would see if you can install requests-futures from https://github.com/ross/requests-futures (including the concurrent.futures backported from python 3, if you are running python 2).

Aaron
  • 2,341
  • 21
  • 27
  • 1
    The code looks like it's using the [requests library async module](http://docs.python-requests.org/en/v0.10.6/user/advanced/#asynchronous-requests) – Kevan Ahlquist Jan 28 '16 at 18:35