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

Use of resolve generates coroutine never awaited warnings #37

Open
cbehopkins opened this issue Oct 4, 2024 · 0 comments
Open

Use of resolve generates coroutine never awaited warnings #37

cbehopkins opened this issue Oct 4, 2024 · 0 comments

Comments

@cbehopkins
Copy link

I have some code that uses resolves, I get the following warning:

831aC:\Python3126\Lib\pathlib.py:1250: RuntimeWarning: coroutine 'AsyncPath.stat' was never awaited
  p.stat()
Object allocated at (most recent call last):
  File "C:\Python3126\Lib\pathlib.py", lineno 1250
    p.stat()

I believe this is caused by, although resolve is awaited, the implementation of resolve uses await to_thread on super().resolve.
The pathlib implementaiton of resolve then does p.stat, which because p (which in the resolve method is generated from self and so) is an AsyncPath. This stat then returns a coroutine, rather than being a simple method as in the default Path implementation.

As a workaround resolve can be passed strict=True which skips the stat check. (This does indeed supress the warning)
A quick fix would probably be to have the AsyncPath resolve method pass a reconstructed Path to the called resolve method, rather than self.

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

No branches or pull requests

1 participant