this post was submitted on 04 Oct 2023
0 points (NaN% liked)

Python

6368 readers
14 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

I'm trying to set up a producer/consumer pipeline using asyncio in Python. The goal is to have one coroutine that reads input continuously and puts it into a queue, while another coroutine pulls items from the queue and processes them in the background.

I think I need to use asyncio queues and tasks, but not quite sure how to structure it properly. Could someone provide a simple asyncio producer/consumer queue example? Ideally it would show both coroutines, use asyncio.gather to run them concurrently, and handle the event loop setup/cleanup.

Any help would be really appreciated!

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here