def _exec_nb(self, cmd, cwd=None, env=None, encoding='<STR_LIT:utf-8>'):
self.failed_message = None<EOL>logger.debug("<STR_LIT>",<EOL>'<STR_LIT:U+0020>'.join(cmd), cwd, str(env))<EOL>try:<EOL><INDENT>self.proc = subprocess.Popen(cmd,<EOL>stdout=subprocess.PIPE,<EOL>stderr=subprocess.PIPE,<EOL>cwd=cwd,<EOL>env=env)<EOL>err_thread = threading.Thread(target=self._read_stderr,<EOL>kwargs={'<STR_LIT>': encoding},<EOL>daemon=True)<EOL>err_thread.start()<EOL>for line in self.proc.stdout:<EOL><INDENT>yield line.decode(encoding, errors='<STR_LIT>')<EOL><DEDENT>err_thread.join()<EOL>self.proc.communicate()<EOL>self.proc.stdout.close()<EOL>self.proc.stderr.close()<EOL><DEDENT>except OSError as e:<EOL><INDENT>err_thread.join()<EOL>raise RepositoryError(cause=str(e))<EOL><DEDENT>if self.proc.returncode != <NUM_LIT:0>:<EOL><INDENT>cause = "<STR_LIT>" %(self.failed_message, self.proc.returncode)<EOL>raise RepositoryError(cause=cause)<EOL><DEDENT>
Run a command with a non blocking call.

        Execute `cmd` command with a non blocking call. The command will
        be run in the directory set by `cwd`. Enviroment variables can be
        set using the `env` dictionary. The output data is returned
        as encoded bytes in an iterator. Each item will be a line of the
        output.

        :returns: an iterator with the output of the command as encoded bytes

        :raises RepositoryError: when an error occurs running the command