question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`prompt_async` is blocking on windows

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
eric-wiesercommented, May 16, 2017

eventloop.utils.AsyncioTimeout is also missing, even though 'AsyncioTimeout' in eventloop.utils.__all__.

Are there no automated tests on the 2.0 branch to catch these things?

0reactions
BYKcommented, Jun 1, 2020

Tested this with the modernized version of the initial case:

import asyncio
from prompt_toolkit import PromptSession
from prompt_toolkit.patch_stdout import patch_stdout

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


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


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

Seems to be working as expected (prompt line is continuously pushed down even when typing).

Read more comments on GitHub >

github_iconTop Results From Across the Web

AuthSession not working for Authorization Code Flow #8300
Under the hood, code exchange is performing a fetch request so I wouldn't consider this to be explicitly blocking anyone. Generally ...
Read more >
Login blocking on Windows 10 browsers - Microsoft Community
So if I install some kind of OS in between Windows and my browsers the login works, but will not work on any...
Read more >
Authentication - Expo Documentation
Build requests using AuthSession.useAuthRequest() , the hook allows for async setup which means mobile browsers won't block the authentication. Be sure to ...
Read more >
Turn Off "Block Third-Party Cookies" in Chrome for Windows
Use the following procedure to ensure that the setting “Block third-party cookies” is turned off. Solution. In the Chrome browser window, click the...
Read more >
Configuring your web browser to allow pop-up windows
Most web browsers include a feature to block pop-up windows.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found