Skip to content

Problems integrating trio_asyncio & distributed/tornado #22

@dhirschfeld

Description

@dhirschfeld

Moved from python-trio/trio#552 (comment)

import asyncio
from functools import partial
import trio
import trio_asyncio
from dask.distributed import Client


async def f():
    async with trio_asyncio.open_loop() as loop:
        client = await loop.run_asyncio(partial(Client, asynchronous=True))
        future = client.submit(lambda x: x + 1, 10)
        return await loop.run_future(future)

res = trio.run(f)

results in the error:

C:\Miniconda3\lib\site-packages\trio_asyncio\loop.py:33: TrioDeprecationWarning: trio.TaskLocal.__init__ is deprecated since Trio 0.4.0; use contextvars.ContextVar instead (https://github.com/python-trio/trio/issues/420)
  _current_loop = trio.TaskLocal(loop=None, policy=None)

Exception in default exception handler
Traceback (most recent call last):
  File "C:\Miniconda3\lib\asyncio\base_events.py", line 1291, in call_exception_handler
    self.default_exception_handler(context)
  File "C:\Miniconda3\lib\site-packages\trio_asyncio\async_.py", line 50, in default_exception_handler
    raise exception
  File "C:\Miniconda3\lib\site-packages\trio_asyncio\base.py", line 529, in _reader_loop
    await _wait_readable(fd)
  File "C:\Miniconda3\lib\site-packages\trio\_core\_io_windows.py", line 378, in wait_socket_readable
    await self._wait_socket("read", sock)
  File "C:\Miniconda3\lib\site-packages\trio\_core\_io_windows.py", line 361, in _wait_socket
    raise TypeError("need a stdlib socket")
TypeError: need a stdlib socket
<snip>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions