Skip to content

ApplicationCommunicator cancels the application future unnecessarily? #417

@fish-face

Description

@fish-face

I am referring to this part of the receive_output method:

            else:
                self.future.cancel()
                try:
                    await self.future
                except asyncio.CancelledError:
                    pass

What I have experienced is that if you, in a test, call receive_output when there is none available, you not only get a TimeoutError, but you cannot catch that exception and proceed, because the whole application has been cancelled; any further attempts to receive output, or even reconnect the communicator, will fail with CancelledError.

There is a question mark in the title because I certainly do not know if this is necessary in some other circumstance! But I don't see a reason to do this, hence raising an issue.

Assuming there is a reason for this then it may help to have some context on why I would want to receive_output when none is available: it's handy when you don't actually know how much output you're expecting, because you can do something like:

outputs = []
while True:
    outputs.append(await communicator.receive_output())
...

Of course, there are checks that one could perform to see whether output is available; but maybe there's no need to. If there is a need, my tests are actually synchronous so performing them is more annoying and costly than it might seem :P

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