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 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.

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.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nest_asyncio-0.9.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nest_asyncio-0.9.2.tar.gz
Algorithm Hash digest
SHA256 76237bca72c9ac74677836293daf4953ed3eb0e60af24780527b575d16b458be
MD5 f9fe8fd064ea52988024b60bb71ccd80
BLAKE2b-256 22b1ac2532b0daae78faf30578d2d86962b46848772e687148c409588a3ae7f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nest_asyncio-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.4.3 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.6

File hashes

Hashes for nest_asyncio-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c8cd3716ddb7313c77d6eb133c1ac4da317708564b2cc5b90663c4bd095c90f
MD5 9d3148f7d4cefe97fd29595c8f0693a7
BLAKE2b-256 0ae99cee04a86f91b1eba1288ffc228948e2d61e6ca3ef3cdc389a794ba8cb85

See more details on using hashes here.

Supported by

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