aioethereum icon indicating copy to clipboard operation
aioethereum copied to clipboard

Client assume use of uvloop when available

Open DurandA opened this issue 7 years ago • 4 comments

client.py change the event loop policy when uvloop is installed (asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())).

When importing aioethereum, this cause some weird behavior when creating tasks using default event loop from asyncio: RuntimeError: Task <Task pending coro=<go() running at run_server.py:138>> got Future <Future pending> attached to a different loop

DurandA avatar Dec 21 '17 12:12 DurandA

@DurandA , could you provide an example of code which you running?

m-bo-one avatar Dec 22 '17 01:12 m-bo-one

Here is a snippet that demonstrate this behavior:

import asyncio

loop = asyncio.get_event_loop()

import aioethereum

async def go():
    client = await aioethereum.create_ethereum_client(
        'http://localhost:8545', loop=loop)
    await asyncio.sleep(0.1)
    val = await client.web3_clientVersion()
    print(val)

loop.create_task(go())
loop.run_forever()

This will run fine when uvloop is not installed but return RuntimeError: Task <Task pending coro=<go() running at aioethereum-fail.py:11>> got Future <Future pending> attached to a different loop otherwise.

DurandA avatar Mar 27 '18 13:03 DurandA

solved?

kuifu avatar Sep 13 '18 15:09 kuifu

@kuifu not reproduced

m-bo-one avatar Oct 29 '18 20:10 m-bo-one