I'm working on a Python program that uses cmd
to make an interactive interpreter. One of the commands causes the program to hang, but only in certain terminals. I've tried a few different terminals on Linux, and ran into the issue with all of them. However, whenever I try running it in IDLE
or PyCharm
, I have no issues at all and it behaves as expected.
The only relevant post I could find searching was the first response in Invoking python under CygWin on Windows hangs. This seems like it might be a similar problem, but the solution wouldn't be of much help.
The code below can reproduce the problem. The commands should be run in this order: load, fill, submit. It will hang on submit(depending on terminal).
import cmd
import spynner
b = spynner.Browser(debug_level = spynner.DEBUG)
class Loop(cmd.Cmd):
def do_load(self, line):
b.load("http://joshcurl.com/test/")
b.load_jquery(True)
def do_fill(self, line):
b.fill("input[name=%s]" % "name", "joshua")
def do_submit(self, line):
b.submit("input[value=%s]" % "Submit")
def do_show(self, line):
print b.html
def do_EOF(self, line):
return True
if __name__ == '__main__':
Loop().cmdloop()
In general, is there something different between "standard" Linux terminals and ones such as IDLE and PyCharm's that could cause differing behaviour like this?