doubles icon indicating copy to clipboard operation
doubles copied to clipboard

Add support for asyncio.Future

Open charlax opened this issue 3 years ago • 6 comments

In its current state, doubles's and_return_future only returns concurrent.futures.Future or tornado.concurrent.Future.

def _get_future():
    try:
        from concurrent.futures import Future
    except ImportError:
        try:
            from tornado.concurrent import Future
        except ImportError:
            raise ImportError(
                'Error Importing Future, Could not find concurrent.futures or tornado.concurrent',
            )
    return Future()

To make it work with asyncio, I had to manually patch _get_future:

from asyncio import Future
from typing import Any

import doubles


def fix_doubles_future() -> None:
    def _get_future() -> Future[Any]:
        return Future()

    doubles.allowance._get_future = _get_future


fix_doubles_future()

There should be a way to configure this globally or on a per-call basis.

Btw, I'd be happy to implement the fix but it seems this repository is not maintained anymore: https://github.com/uber/doubles/issues/145

charlax avatar Feb 11 '22 13:02 charlax

@charlax hi charlax i just ran into this as well, should we fork this repo?

jmaliksi avatar Sep 20 '23 16:09 jmaliksi

@charlax @jmaliksi I hope all is well!

I was already thinking of forking this because I ran into some other issues (see #148).

I will get a new fork up and published, any thoughts on the name?

toddsifleet avatar Sep 20 '23 17:09 toddsifleet

Oh hey friends!

For sure, let's fork! doubles is awesome.

charlax avatar Sep 20 '23 17:09 charlax

doubles....2

jmaliksi avatar Sep 20 '23 18:09 jmaliksi

@charlax @jmaliksi dobles has been launched. It is just at feature parity now, I'll work on improving all the async stuff this week.

toddsifleet avatar Oct 29 '23 20:10 toddsifleet

Oooooh nice thanks Todd!

On Sun, Oct 29, 2023 at 4:40 PM Todd Sifleet @.***> wrote:

@charlax https://github.com/charlax @jmaliksi https://github.com/jmaliksi dobles https://github.com/smartfastlabs/dobles has been launched. It is just at feature parity now, I'll work on improving all the async stuff this week.

— Reply to this email directly, view it on GitHub https://github.com/uber/doubles/issues/146#issuecomment-1784219255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA5NNNWMCB5ZAZM4YPXQALYB25KPAVCNFSM5OEIMLT2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGQZDCOJSGU2Q . You are receiving this because you were mentioned.Message ID: @.***>

charlax avatar Oct 30 '23 02:10 charlax