Это моя первая попытка многопоточности, и я уже столкнулся с многочисленными препятствиями! Таким образом, мой код запускает два потока параллельно, один из которых запускает функцию для получения блоков данных с сервера и помещает их в очередь, а другой, который запускает функцию, которая удаляет блоки данных из очереди и выполняет вычисления, пока очередь не станет пустой. .
Код клиента:
import socket
import turtle
import queue
import threading
#import timeit
from tkinter import *
class GUI:
entries = []
def __init__(self, master):
self.master = master
master.title("Collision Detection")
self.buff_data = queue.Queue()
self.t1 = threading.Thread(target = self.recvData)
self.t2 = threading.Thread(target=self.calculate_threshold)
self.entries = []
self.host = '127.0.0.1'
self.port = 5001
self.s = socket.socket()
self.s.connect((self.host, self.port))
self.create_GUI()
def create_GUI(self):
self.input_label = Label(root, text = "Input all the gratings set straight wavelength values in nm")
self.input_label.grid(row = 0)
self.core_string = "Core "
#entries = []
self.label_col_inc = 0
self.entry_col_inc = 1
self.core_range = range(1, 5)
for y in self.core_range:
self.core_text = self.core_string + str(y) + '_' + '25'
self.core_label = Label(root, text = self.core_text)
self.entry = Entry(root)
self.core_label.grid(row=1, column=self.label_col_inc, sticky=E)
self.entry.grid(row=1, column=self.entry_col_inc)
self.entries.append(self.entry)
self.label_col_inc += 2
self.entry_col_inc += 2
self.threshold_label = Label(root, text = "Threshold in nm")
self.entry_threshold = Entry(root)
self.threshold_label.grid(row = 2, sticky = E)
self.entry_threshold.grid(row = 2, column = 1)
self.light_label = Label(root, text = 'Status')
self.light_label.grid(row = 3, column = 3)
self.canvas = Canvas(root, width = 150, height = 50)
self.canvas.grid(row = 4, column = 3)
# Green light
self.green_light = turtle.RawTurtle(self.canvas)
self.green_light.shape('circle')
self.green_light.color('grey')
self.green_light.penup()
self.green_light.goto(0,0)
# Red light
self.red_light = turtle.RawTurtle(self.canvas)
self.red_light.shape('circle')
self.red_light.color('grey')
self.red_light.penup()
self.red_light.goto(40,0)
self.data_button = Button(root, text = "Get data above threshold", command = self.getData)
self.data_button.grid(row = 5, column = 0)
# function to receive TCP data blocks
def getData(self):
#start = timeit.default_timer()
len_message = self.s.recv(4)
print('len_message', len_message)
bytes_length = int(len_message.decode('utf-8')) # for the self-made server
recvd_data = self.s.recv(bytes_length)
print('data', recvd_data)
self.buff_data.put(recvd_data)
#stop = timeit.default_timer()
#print('Time: ', stop - start) gives 0.0002s
self.t1.start()
self.t2.start()
def recvData(self):
len_message = self.s.recv(4)
print('len_message', len_message)
while len_message:
bytes_length = int(len_message.decode('utf-8')) # for the self-made server
recvd_data = self.s.recv(bytes_length)
print('data', recvd_data)
self.buff_data.put(recvd_data)
len_message = self.s.recv(4)
print('len_message', len_message)
else:
print('out of loop')
self.s.close()
def calculate_threshold(self):
#start = timeit.default_timer()
print('Calculating:')
while not self.buff_data.empty():
print('okay enter')
rmv_data = self.buff_data.get()
stringdata = rmv_data.decode('utf-8')
rep_str = stringdata.replace(",", ".")
splitstr = rep_str.split()
inc = 34
wav_threshold = []
for y in self.entries:
straight_wav = float(y.get())
wav = float(splitstr[inc])
wav_diff = wav - straight_wav
if wav_diff < 0:
wav_diff = wav_diff * (-1)
wav_threshold.append(wav_diff)
inc += 56
threshold = float(self.entry_threshold.get())
for x in wav_threshold:
if (x > threshold):
self.red_light.color('red')
self.green_light.color('grey')
else:
self.red_light.color('grey')
self.green_light.color('green')
#stop = timeit.default_timer()
#print('Time: ', stop - start) gives 0.11s
# function to write into the file
def write_file(self,data):
with open("Output.txt", "a") as text_file:
text_file.write('\t'.join(data[0:]))
text_file.write('\n')
if __name__ == '__main__':
root = Tk()
gui = GUI(root)
root.mainloop()
Я запустил код сервера, чтобы отправить только один блок данных с комментариями обоих потоков, запустил переменные запуска и остановки getData()
и увидел его. для передачи одного блока данных требуется 0,0002 с. Затем я запустил код сервера, чтобы отправить только один блок данных, и запустил переменные запуска и остановки только для calculate_threshold()
и увидел, что для выполнения вычислений требуется 0,12407 с.
На основе этого я удалил timeit
переменных и отправил около 34 блоков данных (из-за ограничения количества слов в теле моего сообщения я показал только несколько ниже) с временной задержкой 0,5 с после отправки 10 блоков данных и заметил, что я получаю это в своей консоли:
C:\Users\PycharmProjects\GUI\venv\Scripts\python.exe C:/Users/PycharmProjects/GUI/GUI_v4.py
len_message b'1685'
data b' 2020/03/02\t14:42:05\t318301\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/03\t14:42:05\t318302\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/04\t14:42:05\t318303\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'Calculating:
okay enterlen_message b'1685'
data b' 2020/03/05\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/06\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/07\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/08\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/09\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/10\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/11\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b'1685'
data b' 2020/03/12\t14:42:05\t318411\t4\t1\t25\t0\t0\t0\t0\t1513,094\t1516,156\t1519,154\t1521,969\t1525,029\t1527,813\t1530,921\t1533,869\t1536,740\t1539,943\t1542,921\t1545,879\t1548,843\t1551,849\t1554,760\t1557,943\t1560,782\t1563,931\t1566,786\t1569,751\t1572,690\t1575,535\t1578,638\t1581,755\t1584,759\t41\t39\t33\t39\t48\t44\t49\t55\t61\t58\t64\t55\t68\t74\t68\t59\t57\t74\t61\t68\t58\t64\t54\t47\t46\t2\t25\t0\t0\t0\t0\t1512,963\t1515,935\t1518,857\t1521,849\t1524,655\t1527,577\t1530,332\t1533,233\t1536,204\t1539,488\t1542,571\t1545,725\t1549,200\t1552,430\t1555,332\t1558,484\t1561,201\t1564,285\t1567,001\t1569,870\t1572,758\t1575,491\t1578,512\t1581,547\t1584,405\t48\t43\t37\t42\t57\t54\t59\t62\t67\t58\t71\t59\t77\t82\t82\t64\t71\t88\t77\t79\t72\t73\t63\t49\t50\t3\t25\t0\t0\t0\t0\t1513,394\t1516,517\t1519,536\t1522,082\t1525,428\t1527,963\t1531,288\t1534,102\t1536,659\t1539,757\t1542,707\t1545,627\t1548,389\t1551,459\t1554,406\t1557,986\t1560,667\t1564,103\t1567,036\t1570,144\t1573,189\t1575,888\t1579,185\t1582,323\t1585,338\t35\t36\t32\t37\t57\t58\t61\t64\t75\t73\t70\t62\t61\t62\t59\t51\t52\t64\t58\t62\t70\t70\t64\t54\t55\t4\t25\t0\t0\t0\t0\t1512,658\t1515,752\t1518,797\t1521,707\t1524,744\t1527,627\t1530,871\t1534,002\t1537,086\t1540,320\t1543,217\t1546,010\t1548,660\t1551,385\t1554,253\t1557,074\t1560,193\t1563,116\t1566,043\t1568,963\t1571,855\t1574,957\t1577,954\t1581,128\t1584,273\t43\t42\t39\t40\t56\t50\t56\t62\t65\t54\t59\t62\t75\t79\t73\t63\t67\t77\t73\t75\t68\t62\t54\t51\t51\t100 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN'
len_message b''
out of loop
okay enter *x 32 times*
Почему после 3-х блоков данных, напечатанных на консоли, появляется пропуск? Почему не печатается оператор печати 'Calculating' и почему он сначала выполняет первый поток (получает все блоки данных), а затем выполняет вычисления второго потока?
Мне нужны оба происходить одновременно. Я понимаю, что второй поток занимает больше времени, но именно поэтому я добавил задержку при отправке данных, чтобы убедиться, что к тому времени, когда будут отправлены 10 блоков данных по 0,0002 с + добавляется задержка 0,5 с = 0,502 с, к тому времени l oop второго потока должно было выполняться 5 раз.
Как я могу убедиться, что они работают параллельно? Учитывая, что мой сервер будет оборудованием, которое будет непрерывно отправлять блоки данных с частотой дискретизации 100 Гц, и не будет ограничений на количество отправляемых блоков данных.