python aiohttp post 的使用

# -*- coding: utf-8 -*-
import datetime, os, sys
import time
import datetime
import socket
import grequests
import json
import asyncio
from aiohttp import ClientSession
tasks = []
tasksResult=[]
a = time.time()
async def request_run(i, semaphore):
    async with semaphore:
        async with ClientSession() as session:
            parameter={"ServiceList":"INTERNET","Host":"www.baidu.com","DataBlockSize":64,"NumberOfRepet":5,"Timeout":1000}
            tmp={}
            tmp=parameter
            tmp["Username"]=i
            url='http://192.168.1.6:8190/public/test/testing/ping'
            async with session.post(url, data=json.dumps(tmp)) as resp:
                #response = await resp.read()
                response = await resp.json()
                print("req")
                print(response)
                reqResult=

你可能感兴趣的:(python,1024程序员节)