1

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?

Community
  • 1
  • 1
joshwget
  • 11
  • 2
  • 6
    Could you try to isolate the problem into a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) that you can paste into your question? You're much more likely to get help here if you give us an MCVE than if we have to wade through thousands of lines of code on another site. – PM 2Ring Oct 29 '14 at 06:36
  • Just a clue on debugging : you could try to add logs (module `logging`) to see more precisely where the application hangs. But if you want help from SO you should really build a MCVE ... – Serge Ballesta Oct 29 '14 at 09:17
  • Thanks for the advice. I'll make a minimal interpreter with only one or two relevant commands. – joshwget Oct 29 '14 at 17:46
  • This could actually be a problem specific to spynner. I'm going to add an issue on Github. – joshwget Oct 29 '14 at 19:07

0 Answers0