Question

I am working on making a GUI which I can use to select arguments like script, and port number to pass to my script. My code is working and I am getting answers from my interpreter but for some unknown reason the GUI stops responding after displaying the result of the running

I tried so many ways to run the interpreter (popen, os.system, popen+thread ...) but still the same result, it always stops responding and I have to force it to stop and kill the process because it keeps using the port.

def interpreter():
    que2.put_nowait(queue[0])
    b = que2.get()
    a = que1.get()
    c = 'python C:\\workspace\\Project_Interpreter\\Tool-v1.0.py -s %s %s' % (b, a)
    ps=sp.Popen(c , stdout=PIPE)

    def stdoutprocess(o):
        while True:
            stdoutdata = o.stdout.readline()
            if stdoutdata:
                sys.stdout.write(stdoutdata)
            else:
                break
    t = threading.Thread(target=stdoutprocess,args=(ps,))
    t.start()
    ps.wait()
    t.join()
    print "Return code", ps.returncode
Was it helpful?

Solution

I managed to figure out what was the problem.In fact I am putting the program on hold waiting for nothing and then I am making the thread wait also, so the program crashes. So long story short, what should be done is remove the two lines

ps.wait()
t.join()

and then it will work properly and you may also retrieve answers in real time !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top