Change blocking

This commit is contained in:
zefirova.am 2023-12-14 01:07:05 +03:00
parent ecf00c92bc
commit 444f35b71f

View File

@ -1,5 +1,6 @@
import cmd import cmd
import threading import threading
from threading import Thread
from queue import Empty, Queue from queue import Empty, Queue
@ -21,7 +22,7 @@ class TurtleDeviceThread(threading.Thread):
else: else:
if (item == 'exit'): if (item == 'exit'):
break break
self.device.execute(item[0], item[1:]) self.device.execute(*item)
self.queue.task_done() self.queue.task_done()
@ -31,7 +32,9 @@ class NoBlockingTurtleShell(cmd.Cmd):
file = None file = None
def __init__(self, turtle_thread: TurtleDeviceThread): def __init__(self, turtle_thread: TurtleDeviceThread):
super(NoBlockingTurtleShell, self).__init__()
self.turtle_thread = TurtleDeviceThread() self.turtle_thread = TurtleDeviceThread()
def do_execute(self, arg): def do_execute(self, arg):
self.turtle_thread.queue.put(arg) self.turtle_thread.queue.put(arg)