Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

run_in_executor incorrectly identifies xmlrpclib methods as coroutines #458

Description

@jimfunk

If a method from an xmlrpclib ServerProxy instance is passed to loop.run_in_executor() in Python 3.5.1, it incorrectly identifies it as a coroutine.

import asyncio
from xmlrpc.client import ServerProxy


async def nonblocking(loop, proxy):
    return await loop.run_in_executor(None, proxy.system.listMethods)


loop = asyncio.get_event_loop()
proxy = ServerProxy('http://127.0.0.1/RPC2/')
loop.run_until_complete(nonblocking(loop, proxy))

Activity

  1. gvanrossum commented on Nov 9, 2016

    @gvanrossum
    Member

    Looks like this is because ServerProxy overrides __gettattr__ to treat any attribute as a potential method.

    Can you work around it by wrapping the listMethods call in a lambda? E.g.

    async def nonblocking(loop, proxy):
        return await loop.run_in_executor(None, lambda: proxy.system.listMethods())

    For a real fix, maybe asyncio.isfuture() should check whether _asyncio_future_blocking is a bool or int? @1st1?

  2. 1st1 commented on Nov 9, 2016

    @1st1
    Member

    asyncio.isfuture is a fairly recent addition, there is no stable Python out there with it. And the most recent version of isfuture should handle proxy & mock objects.

    The problem is actually in asyncio.iscoroutinefunction, I've opened a PR to fix it: #459.

  3. 1st1 commented on Nov 15, 2016

    @1st1
    Member

    Closing the issue, the PR to fix it has just been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions