Skip to content

AnyIO implementation of asynchronous streams #320

Open

Description

@thedrow

Using streamz with an event loop such as trio is currently not possible since Tornado only supports AsyncIO if it is available.

If we had an implementation that uses AnyIO, we could use any event loop we'd desire including tornado.

Activity

  1. CJ-Wright commented on Mar 30, 2020

    @CJ-Wright
    Member

    What would that entail?

  2. CJ-Wright commented on Mar 30, 2020

    @CJ-Wright
    Member

    Also how would that interact with dask?

  3. martindurant commented on Mar 30, 2020

    @martindurant
    Member

    Indeed, a dask client requires an event loop. It is possible to supply an event loop instance at client creation, and I don't know exactly what it required of that loop instance - probably anything asyncio compliant. However, dask's loop can also run in a separate thread, so maybe it is possible to have two loops going (which may get complicated when actually dealing with dask-streamz).

  4. thedrow commented on Mar 30, 2020

    @thedrow
    Author

    It's possible but not necessary if you aren't using dask.

  5. martindurant commented on Mar 30, 2020

    @martindurant
    Member

    Have you tried using the anyIO (or other) loop for dask too? That would be the favourite solution if it works. Otherwise, I think I do basically agree that streamz should work regardless, but in practice, it may be tricky to demarcate dask-free parts of the code.

  6. thedrow commented on Mar 30, 2020

    @thedrow
    Author

    There is no AnyIO implementation for dask.
    There's an AsyncIO implementation and a Tornado implementation.
    I have never used dask so no on both accounts.

    It might be possible to run dask with trio-asyncio but I haven't really checked.

    I want to implement streamz on another framework.

  7. thedrow commented on Mar 30, 2020

    @thedrow
    Author

    This framework should not tie itself to a specific event loop.
    What if the next best thing comes around and everybody wants to use it?

  8. martindurant commented on Mar 30, 2020

    @martindurant
    Member

    True, but being able to use Dask is important too. If you can implement anyIO (or something else) for the non-Dask code without greatly complicating the code, we would consider it. Of course we would still prefer smooth interaction between streamz and Dask on any io-loop.

  9. thedrow commented on Mar 30, 2020

    @thedrow
    Author

    If you'd like to integrate Dask with other event loops I suggest taking it upstream.

    I took a look at the code. It is currently impossible since you are tightly coupled with the Tornado event loop.

  10. martindurant commented on Mar 30, 2020

    @martindurant
    Member

    Would uvloop, which is asyncio compatible, be a solution for you?

  11. dhirschfeld commented on Mar 31, 2020

    @dhirschfeld
  12. thedrow commented on Mar 31, 2020

    @thedrow
    Author

    Would uvloop, which is asyncio compatible, be a solution for you?

    No. I need trio support.

  13. RiverAi7z commented on Sep 17, 2024

    @RiverAi7z

    Would uvloop, which is asyncio compatible, be a solution for you?

    Could you please give some example of using python default asynicio and uvloop?

  14. martindurant commented on Sep 17, 2024

    @martindurant
    Member

    https://streamz.readthedocs.io/en/latest/async.html has asyncio examples and tornado syntax too.

    To use a uvloop, you can make it the default one with something like

    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

    and all further use can be the same. I don't know if there's any further configuration or control you can do with it.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions