#!/usr/bin/python3
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import _thread
import time
# 为线程定义一个函数
def addtask():
for n in range(1,1001):
url ="https://xxxxxxxx.com/graphql"
taskname ="task" +str(n)
headers = {
"authorization":"xxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
date = {"operationName":"addTask","variables": {"streamID":137,"name": taskname},
"query":"mutation addTask($name: String!, $streamID: ID!) {\n createNewTask(input: {streamID: $streamID, name: $name}) {\n id\n name\n __typename\n }\n}\n"}
response = requests.request("post", url,headers=headers,json=date,verify=False)
# time.sleep(1)
# print(name)
print(response.text)
# 创建20个线程
try:
for nin range(1,21):
_thread.start_new_thread(addtask, ())
except:
print ("Error: 无法启动线程")
while 1:
pass