Skip to content

Process.__repr__ displays stale information #1315

@dhirschfeld

Description

@dhirschfeld

As discussed on gitter Process.__repr__ doesn't show the latest information:

In [28]: process = await trio.open_process(['git', 'status'], stdout=subprocess.DEVNULL)

In [29]: process
Out[29]: <trio.Process ['git', 'status']: running with PID 9888>

In [30]: !powershell -Command { 'ps -Id 9888' }
ps : Cannot find a process with the process identifier 9888.
At line:1 char:1
+ ps -Id 9888
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (9888:Int32) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Commands.GetProcessCommand


In [31]: process
Out[31]: <trio.Process ['git', 'status']: running with PID 9888>

In [32]: await process.wait()
Out[32]: 0

In [33]: process
Out[33]: <trio.Process ['git', 'status']: exited with status 0>

Just opening this issue in case the situation can be improved by e.g. calling poll internally:

maybe __repr__ should automatically call .poll() to give up to date info?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions