Skip to main content

Backport python 3.13 asyncio Queue with shutdown.

Project description

backports.asyncio.queues: Backport of the standard library module asyncio.queues

Python 3.13 adds a shutdown method to asyncio.queue.Queue. This package ports the feature to Python 3.9 through 3.12.

Consult the 3.13 specific documentation on Queue for usage.

Installation and depending on this library

This module is called backports.asyncio.queues on PyPI. To install it in your local environment, use:

pip install backports.asyncio.queues

Use

The backports.asyncio.queues module should be a drop-in replacement for the Python 3.13 standard library module asyncio.queue. If you do not support anything earlier than Python 3.13, you do not need this library; you may want to use this idiom to "fall back" to backports.asyncio.queues:

try:
    from asyncio.queues import Queue, QueueShutDown
except ImportError:
    from backports.asyncio.queues import Queue, QueueShutDown

You must import QueueShutDown in order for this pattern to work, as it doesn't exist on Python 3.12 and earlier.

Alternatively, you can use sys.version_info explicitly:

import sys

if sys.version_info >= (3, 13):
    from asyncio.queues import Queue
else:
    from backports.asyncio.queues import Queue

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

backports_asyncio_queues-0.1.2.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

backports_asyncio_queues-0.1.2-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

Supported by

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