Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get_running_loop() instead of get_event_loop() #1774

Closed
wants to merge 1 commit into from
Closed

Use get_running_loop() instead of get_event_loop() #1774

wants to merge 1 commit into from

Conversation

jiaosenvip
Copy link

@jiaosenvip jiaosenvip commented Jul 29, 2023

This PR proposes to change get_event_loop() to get_running_loop() in prompt_toolkit/application.py to improve compatibility on Windows.

As mentioned in other places of the prompt_toolkit codebase, get_running_loop() is the recommended way to get the event loop since Python 3.7, because it returns the running loop for the current context instead of strictly the default loop.

This is important for prompt_toolkit to work properly on Windows, where the default loop may not be compatible. Using get_running_loop() can avoid potential issues with an incompatible default loop.

The usage of get_event_loop() in prompt_toolkit/application.py seems to be leftover from early development, and was likely forgotten to be changed when adding Windows support. All other occurrences have been updated to use get_running_loop().

Replacing this instance of get_event_loop() with get_running_loop() should improve portability without introducing side effects. It follows the prompting_toolkit's design goal of being cross-platform compatible.

Therefore, I propose we make this change to remain consistent with the rest of the codebase and avoid potential bugs on Windows. Please consider merging this PR to use get_running_loop() instead of get_event_loop() in application.py. Let me know if any changes are necessary. Thanks!

This PR proposes to change get_event_loop() to get_running_loop() in `prompt_toolkit/application.py` to improve compatibility on Windows.

As mentioned in other places of the prompt_toolkit codebase, get_running_loop() is the recommended way to get the event loop since Python 3.7, because it returns the running loop for the current context instead of strictly the default loop.

This is important for prompt_toolkit to work properly on Windows, where the default loop may not be compatible. Using get_running_loop() can avoid potential issues with an incompatible default loop.

The usage of get_event_loop() in `prompt_toolkit/application.py` seems to be leftover from early development, and was likely forgotten to be changed when adding Windows support. All other occurrences have been updated to `use get_running_loop()`.

Replacing this instance of get_event_loop() with get_running_loop() should improve portability without introducing side effects. It follows the prompting_toolkit's design goal of being cross-platform compatible.

Therefore, I propose we make this change to remain consistent with the rest of the codebase and avoid potential bugs on Windows. Please consider merging this PR to use get_running_loop() instead of get_event_loop() in application.py. Let me know if any changes are necessary. Thanks!
@jiaosenvip jiaosenvip closed this by deleting the head repository Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant