异步调试接口
import aiohttp
import asyncio
import time
import hmac
import hashlib
data = input('请输入请求报文 \n')
transfer = b''
sign = hmac.new(transfer, data.encode(encoding='utf-8'), hashlib.md5).hexdigest()
print('验签 :', sign)
url = ''
print('请求地址 :', url)
async def test():
async with aiohttp.ClientSession() as session:
async with session.post(url, data=data) as resp:
print(resp.status)
print(await resp.text())
start_time = time.time()
loop = asyncio.get_event_loop()
tasks = []
for i in range(30):
task = asyncio.ensure_future(test())
tasks.append(task)
loop.run_until_complete(asyncio.wait(tasks))
print('耗时 : ', time.time()-start_time)
import aiohttp
import asyncio
import time
import hmac
import hashlib
data = input('请输入请求报文 \n')
transfer = b''
sign = hmac.new(transfer, data.encode(encoding='utf-8'), hashlib.md5).hexdigest()
print('验签 :', sign)
url = ''
print('请求地址 :', url)
async def test():
async with aiohttp.ClientSession() as session:
async with session.post(url, data=data) as resp:
print(resp.status)
print(await resp.text())
start_time = time.time()
loop = asyncio.get_event_loop()
tasks = []
for i in range(30):
task = asyncio.ensure_future(test())
tasks.append(task)
loop.run_until_complete(asyncio.wait(tasks))
print('耗时 : ', time.time()-start_time)