fix(agent): each request captures only its own output

Closes #19 (closed).

Cause of the JSONDecodeError and the []: the agent runs requests on a thread pool, and exec captured output with contextlib.redirect_stdout, which swaps sys.stdout for the whole process. Two requests at once — a client's command and the master console's poll — wrote into each other's capture: jobs cancel returned a poll's []; a followed install got an empty jobs log --json.

  • agent.py: _ThreadStream stands in for sys.stdout/sys.stderr once; a capturing thread writes to its own buffer, others to the original stream (or nowhere, under pythonw).
  • cli.py: a job command with --help/-h is not followed; only a one-word last line is taken as a job id.
  • client.py: an unreadable jobs log reply raises BenchClientError saying the job is still on the bench, instead of a traceback an operator retries.

Three new tests in test_agent.py; each fails without the fix.

Merge request reports

Loading
Loading