我在python 2.7上有一个项目。我需要进行异步发布以连接AWS。我使用asyncio在python 3.5中有一个异步代码。但是我的代码需要在python2.7 2.7上工作。请指导我如何解决此问题。
import asyncio
import json
from aiohttp import ClientSession
HEADERS = {'Content-type':'application/json'}
async def hello(url):
data = {"mac": 'mm','minor':3,'distance':1,'timestamp':4444,'uuid':'aa','rssi':1,'tx':34}
async with ClientSession() as session:
async with session.post(url,json=data) as response:
response = await response.read()
print(response)
loop = asyncio.get_event_loop()
url = "http://192.168.101.74:9090/api/postreader"
while True:
loop.run_until_complete(hello(url))