python 2.7中的异步帖子调用?

时间:2018-07-10 09:59:59

标签: python python-2.7 asynchronous rest-client

我在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','major1,'minor':3,'distance':1,'timssseStamp':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()
while True:
loop.run_until_complete(hello("http://192.168.101.74:9090/api/postreader"))

1 个答案:

答案 0 :(得分:0)