调用外部进程时,Python脚本会挂起

时间:2012-01-30 01:57:45

标签: python linux

我编写了一个Python脚本,用作简单的GUI前端。我需要每隔五秒从“wimaxc”进程获得定期更新。这就是我所做的:

import gtk.glade, re, thread, wimax_functions
from os import sys
from timer import RepeatTimer
from subprocess import Popen, PIPE, STDOUT

def RunCommand(command):
    p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
    output = p.stdout.read()
    return output

class RoyalBengalWiMAX:

    def __init__(self):
        self.window = gtk.glade.XML('gui.xml', 'window1')
        dic = {"on_window1_destroy" : self.quit,
               "on_information_click" : self.Set_Status,}
        self.window.signal_autoconnect(dic)
        self.Set_Status()

    def quit(self, obj):
        gtk.main_quit()
        sys.exit(1)

    def Get_Status(self):
        #Do Someting        

    def Set_Status(self):
        r = RepeatTimer(5.0, self.Get_Status, 10)
        r.start()

RoyalBengalWiMAX()
gtk.main()

我从这里使用了RepeatTimer类:g-off.net/software/a-python-repeatable-threadingtimer-class

我运行它后,我的脚本没有响应!需要帮助!

0 个答案:

没有答案