-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSI.py
39 lines (24 loc) · 871 Bytes
/
RSI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import socket
PORT = 8688
ADDR = "localhost"
def socket_ini():
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((ADDR, PORT))
server_socket.listen(10)
connection, addr = server_socket.accept()
print("[INFO]\t", addr, "connected")
return connection, server_socket
def thread_rsi(stop_event, data):
msg = ""
connection, server_socket = socket_ini()
while not stop_event.is_set():
msg = connection.recv(1024).decode()
if "END CONNECTION" in msg:
break
rsi = msg.split(',')
try:
data["RSI"] = [float(m) for m in reversed(rsi)]
except:
print("[INFO]\tError trying to convert to float, ignored");
connection.close()
server_socket.close()