File: __init__.py

package info (click to toggle)
python-aiosmtpd 1.4.6-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,016 kB
  • sloc: python: 8,064; makefile: 159
file content (21 lines) | stat: -rw-r--r-- 633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Copyright 2014-2021 The aiosmtpd Developers
# SPDX-License-Identifier: Apache-2.0
import asyncio
import warnings


__version__ = "1.4.6"


def _get_or_new_eventloop() -> asyncio.AbstractEventLoop:
    loop = None
    with warnings.catch_warnings():
        warnings.simplefilter("error")
        try:
            loop = asyncio.get_event_loop()
        except (DeprecationWarning, RuntimeError):  # pragma: py-lt-310
            if loop is None:  # pragma: py-lt-312
                loop = asyncio.new_event_loop()
                asyncio.set_event_loop(loop)
    assert isinstance(loop, asyncio.AbstractEventLoop)
    return loop