def start(self):
        """Spawn the task.

        Throws RuntimeError if the task was already started."""
        if self.pipe is not None:
            raise RuntimeError("Cannot start task twice")

        self.ioloop = tornado.ioloop.IOLoop.instance()
        if self.timeout > 0:
            self.expiration = self.ioloop.add_timeout(time.time() + self.timeout, self.on_timeout)
        self.pipe = subprocess.Popen(**self.args)

        self.streams = [(self.pipe.stdout.fileno(), []),
                        (self.pipe.stderr.fileno(), [])]
        for fd, d in self.streams:
            flags = fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NDELAY
            fcntl.fcntl(fd, fcntl.F_SETFL, flags)
            self.ioloop.add_handler(fd,
                                    self.stat,
                                    self.ioloop.READ | self.ioloop.ERROR)
dataset/ETHPy150Open vukasin/tornado-subprocess/tornado_subprocess/__init__.py/GenericSubprocess.start/original