简体   繁体   English

Websocket python

[英]Websocket python

Background:背景:

  • I need to read a csv file and establish websocket connection using things from the csv file.我需要读取 csv 文件并使用 csv 文件中的内容建立 websocket 连接。
  • The script will check the csv file every second.该脚本将每秒检查 csv 文件。
  • If a new element was added to the.csv file then the websocket will restart a new connection.如果将新元素添加到 .csv 文件,则 websocket 将重新启动新连接。
  • In the meantime, the script will continue to receive data from the server.同时,脚本将继续从服务器接收数据。
  • Writtend in python写在 python

example of.csv file: [1]: https://i.stack.imgur.com/drikH.png例如.csv 文件:[1]: https://i.stack.imgur.com/drikH.png

I not sure how to receive the data continuously while checking the csv file.在检查 csv 文件时,我不确定如何连续接收数据。

maybe async?也许是异步的? Any suggestions?有什么建议么?

Use threading in reading and writing the csv file.在读取和写入 csv 文件时使用线程。 When the server receives the data, store the data in a list and it will act as a queue.当服务器接收到数据时,将数据存储在一个列表中,它将充当一个队列。 Inside the thread function you will restart the connection.在线程 function 内,您将重新启动连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM