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

Flaky tests: coroutine 'InProc.write' was never awaited #6551

Closed
gjoseph92 opened this issue Jun 9, 2022 · 9 comments · Fixed by #6865
Closed

Flaky tests: coroutine 'InProc.write' was never awaited #6551

gjoseph92 opened this issue Jun 9, 2022 · 9 comments · Fixed by #6865
Assignees
Labels
flaky test Intermittent failures on CI.

Comments

@gjoseph92
Copy link
Collaborator

gjoseph92 commented Jun 9, 2022

Catch-all issue for flaky tests with tracebacks like

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <coroutine object InProc.write at 0x7fd864183ec0>
E               
E               Traceback (most recent call last):
E                 File "/usr/share/miniconda3/envs/dask-distributed/lib/python3.8/warnings.py", line 506, in _warn_unawaited_coroutine
E                   warn(msg, category=RuntimeWarning, stacklevel=2, source=coro)
E               RuntimeWarning: coroutine 'InProc.write' was never awaited

I would imagine there's some core problem that could be fixed to make all these tests work.

Some known failures (feel free to add more in comments):

@graingert do you have any ideas? Weren't you looking at this at some point?

@gjoseph92 gjoseph92 added the flaky test Intermittent failures on CI. label Jun 9, 2022
@graingert
Copy link
Member

maybe this? python/cpython#31003

@graingert
Copy link
Member

ah no it's this

nbytes = yield self.comm.write(
payload, serializers=self.serializers, on_error="raise"
)

@fjetter
Copy link
Member

fjetter commented Jun 21, 2022

xref #6389

@gjoseph92
Copy link
Collaborator Author

Would that be resolved just by switching to asyncio? I don't actually see what's causing it to not be awaited. Is it if the _background_send coroutine gets cancelled while it's awaiting self.comm.write? AFAIU _background_send actually can't be cancelled since we don't have a handle on it.

@graingert
Copy link
Member

Would that be resolved just by switching to asyncio

no it's switching to await that fixes it here - because it moves the yield point after the Coroutine has been awaited

Is it if the _background_send coroutine gets cancelled while it's awaiting self.comm.write

No the issue is the generator getting garbage collected and raising the GeneratorExit out of the yield here rather than the Future that write goes on to yield from

@gjoseph92
Copy link
Collaborator Author

Ah, so just switching to async instead of @gen.coroutine.

@fjetter
Copy link
Member

fjetter commented Jun 22, 2022

Is there any known issue that would stop us from switching it?

@hendrikmakait
Copy link
Member

XREF: #6389

@gjoseph92
Copy link
Collaborator Author

@graingert and I will write up a ticket or comment on what approach we're going to take here. Refactoring BatchedSend to use asyncio right now may not help/be hard, because we don't have something to hang the long-lived task off of yet. We'll probably just ignore the warning for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky test Intermittent failures on CI.
Projects
None yet
4 participants