标题:求助 web socket 多线程发送问题
取消只看楼主
weilai911
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-1-26
 问题点数:0 回复次数:2 
求助 web socket 多线程发送问题
程序代码:
import websocket
from threading import Thread
import time
import sys
  
def on_message(ws, message):
  print(message)
  
def on_error(ws, error):
  print(error)
  
def on_close(ws):
  print("### closed, reconnecting... ###")
  ws.run_forever()

 
def on_open(ws):
  ws.send('[bct295cneqru]')
  def run(*args):
    while True:
      time.sleep(20)
      ws.send("2")

 
    print("重新连接吧")
  
  Thread(target=run).start() 
   
if __name__ == "__main__":
  
  websocket.enableTrace(False)
  host = "ws://127.0.0.1:8080"
  ws = websocket.WebSocketApp(host,
                on_message=on_message,
                on_error=on_error,
                on_close=on_close)
  ws.on_open = on_open
  ws.run_forever()

这是单线程链接ws的方法
我现把我取到的值同时连接并发送应该如何操作
具体值如下:
dl9vwa3ocusz
edt1ee6y3b2m
ectdd89xlk0t
ea4way47oh16
dcghrydcr26w
aibc11p8lcfc
edb42uh2h1h7
ee11pfceejte
ea34crwyvr5r
dilhf68m9ayk
cjr4x33616ci
ed109mgitpo0
dloi1rr4xwzk
ee2u0u9kkg2i
cl12pd9eouua
ac34utf286m7
cc4qqex3m4g1
eb64l81gyarv
ecngg4k3idki
ecvelk45hkve
eadfyhqs9i1u
dkp82puo72qv
edhsteja6qd3
da7046a1n4s0
de1h69fzsdmh
dlulengz4nh4
ec9opdgzind9
clf6hkv9z17m
ed2993li3ku4
edk9giy5oei6
ecro2st2zfux
dfmy4jkfaqp4
cibpmmao632m
ee7ck4a5d0i7
digq81bs4wn5
edu4q4d59t8i
df4r032dide8
acmnjv6e342h
df4z8y40rwlu
ac5a6k5un64x
edkv5lo9ojj5
dkbsd5rco0e6
ec27855o0x25
dgsgk7htp4zg
edbs6coahcy6
dhl55bs4pnnh
ecnra934hxm2
dkunpsrps31q
ddqgz0hfqu04
dl3asf3kq739
aeilp6wdv0w0
dk6uf7pgxxps
dkkrph2btbzx
dlcst4on9q2p
ee65rbqbw5nf
ebb8mm0spajg
cglfm6nmt4ob
dd2yltp155l4
ddu3oa2nvn90
ed4x7094pe7u
ee85y1r364jo
dbsek6s7n2bm
dkt5eusaursx
ee1vs92892k2
ecgtg232kld9
dblakip92xbl
y7s1dlz7t29
cg24xn4qy2nh
dgutm5822l8v
eaedac9zegfw
ee959jyid7f5
ea7x5ob0d7qi
dhvidp84pi32
df353c35dim6
dk38ahd7vqjc
edup7qaesy72
ee7ynrbiprrs
ee5xw304o2x4
djd7rcuadmzd
ee55c4r9u0x0
ee3smnl92apv
ee27t055s43c
ee1n0g3nznfe
ec2n7ndd6xni
ec2hoxs3ndcx
ec2692hzmh5u
ec193fbnauk4
eag1m6en8brm
cf3ur79judh5
ee3pvdwe7d17
edl61dj5biek
ee133jdyz5hq
ed14jv11c8ir
ee61nqzwnufe
ee2e7nkcpat9
ee13kemjz44y
ebmn15zhxdyf
eeex7lw5ciax
edfzi8rkr16b
ee4t0n3f9xka
ee8hfeersb06
dgpn7qupt5pp
detn1b91csw0
eefnzdgi11kl
eebetq9fth1o
cen8tzfno5s4
搜索更多相关主题的帖子: print 发送 def import web 
2022-05-16 11:54
weilai911
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-1-26
得分:0 
有没有大神帮帮忙
2022-05-17 08:31
weilai911
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-1-26
得分:0 
有没有大神帮帮忙
2022-05-23 14:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509092-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.102054 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved