python_sse长连接压测

from threadpool import ThreadPool, makeRequests
from sseclient import SSEClient
import time


def connect(a):
time.sleep(a % 1)
# sse长连接请求结果,将实时打印返回的数据响应
messages = SSEClient('url')
for msg in messages:
if msg == "":
print("返回数据为空")
else:
print(msg)


if __name__ == "__main__":
# 设置并发连接数
pool = ThreadPool(100)
test = list()
for i in range(100):
test.append(i)
result = makeRequests(connect, test)
[pool.putRequest(req) for req in result]
pool.wait()
上一篇:springboot服务端消息推送(SSE技术)


下一篇:苹果Mac菜单栏天气预报小工具:Weather Guru