File: compat.py

package info (click to toggle)
python-promise 2.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 2,681; sh: 13; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
try:
    from inspect import iscoroutine
except ImportError:

    def iscoroutine(obj):  # type: ignore
        return False


try:
    from asyncio import Future, ensure_future  # type: ignore
except ImportError:

    class Future:  # type: ignore
        def __init__(self):
            raise Exception("You need asyncio for using Futures")

        def set_result(self):
            raise Exception("You need asyncio for using Futures")

        def set_exception(self):
            raise Exception("You need asyncio for using Futures")

    def ensure_future():  # type: ignore
        raise Exception("ensure_future needs asyncio for executing")


try:
    from .iterate_promise import iterate_promise
except (SyntaxError, ImportError):

    def iterate_promise(promise):  # type: ignore
        raise Exception('You need "yield from" syntax for iterate in a Promise.')