Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that writing to stdout/stderr does not work on workers #82

Open
nicoddemus opened this issue Aug 12, 2016 · 8 comments
Open

Document that writing to stdout/stderr does not work on workers #82

nicoddemus opened this issue Aug 12, 2016 · 8 comments

Comments

@nicoddemus
Copy link
Member

No description provided.

@pelme
Copy link
Member

pelme commented Sep 29, 2016

Why is this the case? I understand the motivation for remote runs over ssh where stdout/stderr would have to be serialized and communicated back. But what about local runs (i.e. -n1), wouldn't stdout/stderr just be printed from the subprocess?

@RonnyPfannschmidt
Copy link
Member

no, execnet uses stdin/out for communication
so we either have to add explicit support, or remove it

@pelme
Copy link
Member

pelme commented Sep 30, 2016

I see. Would adding explicit support be hard (in theory)? If you think it wouldn't require any insane refactors I would like to give it a try.

print() and log handlers which just dumps stuff on stdout/stderr is such an obvious and easy way to get some debug output. I wrestle with some hard-to-debug intermittent failures on our CI server where I cannot just disable xdist because of slowness.

(I tried to redirect my log messages to some temporary files, but I found it not really straightforward to get that working either, with different nodes etc.)

@RonnyPfannschmidt
Copy link
Member

a python only solution is thinkable (it just needs a handler for stdin/out)
if this gets documented as limited python-only support it seems doable

@pelme
Copy link
Member

pelme commented Oct 26, 2016

(I have not gotten around to do anything about this yet, if anyone is interested, feel free to tackle this!)

@leorochael
Copy link

If execnet uses stdin/stdout for communications but doesn't need stderr, it would be nice if sys.stderr was available when not being captured by pytest.

I know, for example, that stderr is available during pytest_sessionstart() in workers, but in pytest_sessionend() its's not. It'd be nice if it was.

@leorochael
Copy link

leorochael commented Apr 23, 2021

Though I guess one could always resort to printing to sys.__stderr__:

def pytest_sessionfinish(session, exitstatus):
    workerinput = getattr(session.config, 'workerinput', None)
    if workerinput is None:
        print("\nExiting the Master Process, or running serially", file=sys.__stderr__)
    else:
        print(f"\nExiting Worker: {workerinput['workerid']}\n", file=sys.__stderr__)

@jiasli
Copy link

jiasli commented Nov 16, 2021

In my scenario, stderr is indeed shown when --capture=no is specified, according to @RonnyPfannschmidt answered in pytest-dev/pytest#1693 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants