예제 #1
0
class AsyncThread(StoppableThread):
    """
    Thread class that encapsulates an asynchronous command and an
    incremental string file object.
    """

    def __init__(self, cmd, **kwargs):
        super(AsyncThread, self).__init__()
        self.proc = Process(cmd, **kwargs)
        self.out = IncStringIO()
        self.err = IncStringIO()

    def run(self, graceperiod=.1):
        while True:
            poll = self.proc.wait(os.WNOHANG)
            out = self.proc.read()
            err = self.proc.readerr()
            if out != "":
                self.out.write(out)
            if err != "":
                self.err.write(err)
            if poll != None:
                break                
            if self.stopped():
                os.kill(self.proc.pid(), signal.SIGTERM)
                time.sleep(graceperiod)
                os.kill(self.proc.pid(), signal.SIGKILL)
                break
예제 #2
0
class AsyncThread(StoppableThread):
    """
    Thread class that encapsulates an asynchronous command and an
    incremental string file object.
    """
    def __init__(self, cmd, **kwargs):
        super(AsyncThread, self).__init__()
        self.proc = Process(cmd, **kwargs)
        self.out = IncStringIO()
        self.err = IncStringIO()

    def run(self, graceperiod=.1):
        while True:
            poll = self.proc.wait(os.WNOHANG)
            out = self.proc.read()
            err = self.proc.readerr()
            if out != "":
                self.out.write(out)
            if err != "":
                self.err.write(err)
            if poll != None:
                break
            if self.stopped():
                os.kill(self.proc.pid(), signal.SIGTERM)
                time.sleep(graceperiod)
                os.kill(self.proc.pid(), signal.SIGKILL)
                break
예제 #3
0
 def __init__(self, cmd, **kwargs):
     super(AsyncThread, self).__init__()
     self.proc = Process(cmd, **kwargs)
     self.out = IncStringIO()
     self.err = IncStringIO()
예제 #4
0
 def __init__(self, cmd, **kwargs):
     super(AsyncThread, self).__init__()
     self.proc = Process(cmd, **kwargs)
     self.out = IncStringIO()
     self.err = IncStringIO()