Skip to content

UnboundLocalError: local variable 'process' referenced before assignment #1882

@jongiddy

Description

@jongiddy

It's possible for capture_both/run to fail here, and process is not defined in the exception handler.

if pipe_output:
process = sarge.capture_both(args, cwd=cwd, env=env, async_=True)
while all(
command.returncode is None for command in process.commands
):
_read_output(process=process)
process.poll_all()
time.sleep(0.05)
_read_output(process=process)
else:
process = sarge.run(args, cwd=cwd, env=env, async_=True)
stdout_logger.flush()
stderr_logger.flush()
# stderr/stdout are not readable anymore which usually means
# that the child process has exited. However, the child
# process has not been wait()ed for yet, i.e. it has not yet
# been reaped. That is, its exit status is unknown. Read its
# exit status
process.wait()
except Exception: # pragma: no cover pylint: disable=broad-except
for popen_process in process.processes:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions