Skip to content

Avoid using the pollster crate #7748

@umbrageodotus

Description

@umbrageodotus

Is your request related to a problem? Please describe.
As tokio is already being used in jj, pollster is somewhat unneeded and can cause deadlock-type issues.

Describe the solution you'd like
I'd like the uses of pollster to be replaced with using tokio::task::block_in_place, followed by Handle::current (or Handle::try_current on Result types where panicking would be unideal) for retrieving a handle to the tokio runtime, and finishing off with block_on to actually do the blocking. This boilerplate could be handled by a macro or another crate, I don't know.

Describe alternatives you've considered
Modifying anything that actually needs to run async code (for example, traits) to actually return a result and in implementations which don't need async, use std::future::ready.
Note: ideally, as to not wait for the complexity needed for this rewrite, this bandaid fix would be implemented immediately, followed by the future::ready idea asap.

Additional context
Testing would need to be modified. 2 obvious solutions:

  1. Create a tokio runtime for the tests - would also make it more stable as traits provided by tokio are being used INSIDE of what is being tested
  2. Allow for pollster by using Handle::try_current instead of Handle::current and falling back to pollster, although that seems like a bandaid fix

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