Skip to main content

Patch asyncio to allow nested event loops

Project description

PyPi

Introduction

By design asyncio does not allow its event loop to be nested. This presents a practical problem: When in an environment were 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 package will patch asyncio to allow nested use of asyncio.run and loop.run_until_complete.

Installation

pip3 install nest_asyncio

Python 3.5 or higher is required.

Usage

import nest_asyncio
nest_asyncio.apply()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nest_asyncio-0.9.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

nest_asyncio-0.9.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file nest_asyncio-0.9.1.tar.gz.

File metadata

  • Download URL: nest_asyncio-0.9.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.6

File hashes

Hashes for nest_asyncio-0.9.1.tar.gz
Algorithm Hash digest
SHA256 0844af67deda3243389d47cd8754b6775c5c828345e0277beca7bd008d273392
MD5 8879b756bb3715e4155da96f9d40db45
BLAKE2b-256 2af5091a71516ebd25cf3fd7503925a611d18e83dc00cb624aaf97612f112162

See more details on using hashes here.

File details

Details for the file nest_asyncio-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: nest_asyncio-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.6

File hashes

Hashes for nest_asyncio-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b74617777d5746427b641ec08bb98023f36fcadf419b1de2eca45ff27f1ceadf
MD5 1e831c6fd302b02b728afdeb9afb0e89
BLAKE2b-256 229a4d76c36f57847ed655836022f42a36ef19bb44f519278c37edab79d7cfdd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page