prompt-toolkit / prompt-toolkit/python-prompt-toolkit

`prompt_async` is blocking on windows

Open
#505 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Consider the following:

import asyncio

from prompt_toolkit.shortcuts import prompt_async

async def spam():
    while True:
        print("hello");
        await asyncio.sleep(0.1);
        print("World");
        await asyncio.sleep(0.1);


async def my_coroutine():
    while True:
        result = await prompt_async('Say something: ', patch_stdout=True)
        print('You said: %s' % result)

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(my_coroutine(), spam()))
loop.close()

What I expect to happen: The prompt is pushed down by a continual stream of Hello and World

What actually happens: Each time I push a single character, an extra Hello or World is printed - the output does not advance while waiting for a single character.

Contributor guide

No contributing guide indexed for this repository

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

Reproduce the provided prompt_async and asyncio.gather example on Windows, starting at the prompt_async entry point and its interaction with the event loop. Confirm that spam continues printing while the prompt waits for input, and verify the behavior with the example after the issue is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.