src/streamlink/stream/streamprocess.py
def spawn(self, parameters=None, arguments=None, stderr=None, timeout=None, short_option_prefix="-", long_option_prefix="--"):
        """
        Spawn the process defined in `cmd`

        parameters is converted to options the short and long option prefixes
        if a list is given as the value, the parameter is repeated with each
        value

        If timeout is set the spawn will block until the process returns or
        the timeout expires.

        :param parameters: optional parameters
        :param arguments: positional arguments
        :param stderr: where to redirect stderr to
        :param timeout: timeout for short lived process
        :param long_option_prefix: option prefix, default -
        :param short_option_prefix: long option prefix, default --
        :return: spawned process
        """
        stderr = stderr or self.stderr
        cmd = self.bake(self._check_cmd(), parameters, arguments, short_option_prefix, long_option_prefix)
        log.debug("Spawning command: {0}", subprocess.list2cmdline(cmd))

        try:
            process = subprocess.Popen(cmd, stderr=stderr, stdout=subprocess.PIPE)
        except (OSError, IOError) as err:
            raise StreamError("Failed to start process: {0} ({1})".format(self._check_cmd(), str(err)))

        if timeout:
            elapsed = 0
            while elapsed < timeout and not process.poll():
                time.sleep(0.25)
                elapsed += 0.25

            # kill after the timeout has expired and the process still hasn't ended
            if not process.poll():
                try:
                    log.debug("Process timeout expired ({0}s), killing process".format(timeout))
                    process.kill()
                except Exception:
                    pass

            process.wait()

        return process
def spawn(self, parameters=None, arguments=None, stderr=None, timeout=None, short_option_prefix="-", long_option_prefix="--"):
        stderr = stderr or self.stderr
        cmd = self.bake(self._check_cmd(), parameters, arguments, short_option_prefix, long_option_prefix)
        log.debug("Spawning command: {0}", subprocess.list2cmdline(cmd))

        try:
            process = subprocess.Popen(cmd, stderr=stderr, stdout=subprocess.PIPE)
        except (OSError, IOError) as err:
            raise StreamError("Failed to start process: {0} ({1})".format(self._check_cmd(), str(err)))

        if timeout:
            elapsed = 0
            while elapsed < timeout and not process.poll():
                time.sleep(0.25)
                elapsed += 0.25

            # kill after the timeout has expired and the process still hasn't ended
            if not process.poll():
                try:
                    log.debug("Process timeout expired ({0}s), killing process".format(timeout))
                    process.kill()
                except Exception:
                    pass

            process.wait()

        return process
def spawn ( self , parameters = None , arguments = None , stderr = None , timeout = None , short_option_prefix = "-" , long_option_prefix = "--" ) : stderr = stderr or self . stderr cmd = self . bake ( self . _check_cmd ( ) , parameters , arguments , short_option_prefix , long_option_prefix ) log . debug ( "Spawning command: {0}" , subprocess . list2cmdline ( cmd ) ) try : process = subprocess . Popen ( cmd , stderr = stderr , stdout = subprocess . PIPE ) except ( OSError , IOError ) as err : raise StreamError ( "Failed to start process: {0} ({1})" . format ( self . _check_cmd ( ) , str ( err ) ) ) if timeout : elapsed = 0 while elapsed < timeout and not process . poll ( ) : time . sleep ( 0.25 ) elapsed += 0.25 # kill after the timeout has expired and the process still hasn't ended if not process . poll ( ) : try : log . debug ( "Process timeout expired ({0}s), killing process" . format ( timeout ) ) process . kill ( ) except Exception : pass process . wait ( ) return process
Spawn the process defined in `cmd`

        parameters is converted to options the short and long option prefixes
        if a list is given as the value, the parameter is repeated with each
        value

        If timeout is set the spawn will block until the process returns or
        the timeout expires.

        :param parameters: optional parameters
        :param arguments: positional arguments
        :param stderr: where to redirect stderr to
        :param timeout: timeout for short lived process
        :param long_option_prefix: option prefix, default -
        :param short_option_prefix: long option prefix, default --
        :return: spawned process
Spawn the process defined in cmd