pallets / pallets/quart

Async for support for websockets

Open
#118 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
3.7k
Forks
206
PR merge metrics
No merged PRs in 30d

Description

Hello @pgjones,

I just would like to keep up this topic.

There was a discussion in which Nathaniel J. Smith mentioned that async for support for websockets would be more pythonic.

Currently:

while True:
    result = await websocket.receive_json()

The more idiomatic:

async for result in websocket.receive_json():
    ...

It would be great that the async for loop supports both receive and receive_json methods.

Thanks for your help in advance.

Best Regards,
András

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies websocket.receive and websocket.receive_json as the relevant entry points; start by tracing their implementation and current websocket iteration behavior. Confirm how async iteration could support both methods, then verify that receiving JSON and non-JSON messages works through the proposed interface.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.