The implementation is pasted below. However, each time I actually input something in the console, I get this error:
while executing
"::tcl::Bgerror {out of stack space (infinite loop?)} {-code 1 -level 0 -errorcode NONE -errorinfo {out of stack space (infinite loop?)
while execu..."
error in background error handler:
out of stack space (infinite loop?)
This is used by another application(Matplotlib GUI), that instantiates ConsoleInput, and then uses the most recent user entry for itself.
Why is this error happening, and how can I fix ConsoleInput? Is there a way to check if there is pending input, and only read then, rather than loop constantly?
import threading
class ConsoleInput(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.daemon = True
self.exit = False
self.most_recent_entry = None
def run(self):
while not self.exit:
self.most_recent_entry = raw_input()
Here is the relevant part of the GUI that's using the console input:
def __init__(self):
self.console_input = ConsoleInput()
self.console_input.start()
self.run()
def run(self):
self.figure = plt.figure(figsize=(16, 8))
self.figure.canvas.set_window_title(self.title)
self.gen_data()
plt.connect('button_press_event', self.on_fig_update_event)
plt.connect('motion_notify_event', self.on_fig_update_event)
plt.tight_layout()
plt.show()
def gen_data(self):
if self.console_input.most_recent_entry:
print self.console_input.most_recent_entry:
ConsoleInputinstance?ConsoleInput? I think that's probably the piece that needs to change.