File: startasync.py

package info (click to toggle)
python-rx 4.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: python: 39,070; javascript: 77; makefile: 24
file content (18 lines) | stat: -rw-r--r-- 409 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from asyncio import Future
from typing import Callable, TypeVar

from reactivex import Observable, from_future, throw

_T = TypeVar("_T")


def start_async_(function_async: Callable[[], "Future[_T]"]) -> Observable[_T]:
    try:
        future = function_async()
    except Exception as ex:  # pylint: disable=broad-except
        return throw(ex)

    return from_future(future)


__all__ = ["start_async_"]