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

DeprecationWarning at aiofiles.os:8 #74

Closed
HacKanCuBa opened this issue Apr 15, 2020 · 8 comments
Closed

DeprecationWarning at aiofiles.os:8 #74

HacKanCuBa opened this issue Apr 15, 2020 · 8 comments

Comments

@HacKanCuBa
Copy link

HacKanCuBa commented Apr 15, 2020

Hi there! Pytest is correctly complaining about the use of @coroutine decorator at aiofiles.os line 8. This is for the current latest 0.5.0 version.

aiofiles/aiofiles/os.py

Lines 7 to 16 in 258e956

def wrap(func):
@asyncio.coroutine
@wraps(func)
def run(*args, loop=None, executor=None, **kwargs):
if loop is None:
loop = asyncio.get_event_loop()
pfunc = partial(func, *args, **kwargs)
return loop.run_in_executor(executor, pfunc)
return run

The fix would be to use async def directly:

def wrap(func):
    @wraps(func)
    async def run(*args, loop=None, executor=None, **kwargs):
        if loop is None:
            loop = asyncio.get_event_loop()
        pfunc = partial(func, *args, **kwargs)
        return loop.run_in_executor(executor, pfunc)

    return run
@HacKanCuBa HacKanCuBa changed the title DeprecationWarning at aiofiles.os:10 DeprecationWarning at aiofiles.os:8 Apr 15, 2020
@Tinche
Copy link
Owner

Tinche commented Apr 15, 2020

Agreed, could you create a quick PR?

@gyermolenko
Copy link
Contributor

gyermolenko commented Apr 15, 2020

Agreed, could you create a quick PR?

related #54 (! please note that it also changes return type of the wrapped func)

@HacKanCuBa
Copy link
Author

Agreed, could you create a quick PR?

Sure, give me 5' :)

@HacKanCuBa
Copy link
Author

Done in #75

@HacKanCuBa
Copy link
Author

Agreed, could you create a quick PR?

related #54 (! please note that it also changes return type of the wrapped func)

Woops, sorry I missed this. Both PRs clashes, so I guess we need to pick one.

@HacKanCuBa
Copy link
Author

HacKanCuBa commented Apr 15, 2020

I saw that Travis failed in my PR so I checked out the project locally and saw that, at least for py3.8, tests are failing for what is mentioned in #54. With that patch all tests passed.
So, all in all, I think we need to go for #54, which is more complete and fixes other issue, instead of my patch.

@Tinche
Copy link
Owner

Tinche commented Apr 16, 2020

Merged that one in! Can this issue now be closed?

@HacKanCuBa
Copy link
Author

Sure do! I'm closing it. Thanks!

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

Successfully merging a pull request may close this issue.

3 participants