%global pypi_name nest_asyncio Name: python-nest-asyncio Version: 1.5.1 Release: 1%{?dist} Summary: Patch asyncio to allow nested event loops License: BSD URL: https://github.com/erdewit/nest_asyncio Source0: %{pypi_source} BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros %description By design asyncio does not allow its event loop to be nested. This presents a practical problem: When in an environment where the event loop is already running it's impossible to run tasks and wait for the result. Trying to do so will give the error "RuntimeError: This event loop is already running". The issue pops up in various environments, such as web servers, GUI applications and in Jupyter notebooks. This module patches asyncio to allow nested use of asyncio.run and loop.run_until_complete. %package -n python3-nest-asyncio Summary: %{summary} %description -n python3-nest-asyncio By design asyncio does not allow its event loop to be nested. This presents a practical problem: When in an environment where the event loop is already running it's impossible to run tasks and wait for the result. Trying to do so will give the error "RuntimeError: This event loop is already running". The issue pops up in various environments, such as web servers, GUI applications and in Jupyter notebooks. This module patches asyncio to allow nested use of asyncio.run and loop.run_until_complete. %prep %autosetup -n %{pypi_name}-%{version} # Already fixed upstream, not yet released # loop argument for asyncio.gather is deprecated since 3.8 and removed in 3.10 # https://github.com/erdewit/nest_asyncio/commit/245dd5bd5902c724cd5478c865769f69c154f609 sed -i "s/\(.*asyncio.gather(f1(), f2()\), loop=self.loop)).*/\1))/" tests/nest_test.py %generate_buildrequires %pyproject_buildrequires -r %build %pyproject_wheel %install %pyproject_install %pyproject_save_files %{pypi_name} %check PYTHONPATH=%{buildroot}/%{python3_sitelib} %python3 tests/nest_test.py %files -n python3-nest-asyncio -f %{pyproject_files} %license LICENSE %doc README.rst %changelog * Tue Aug 31 2021 Lumír Balhar - 1.5.1-1 - Initial package