Support prompt_toolkit's in_thread#9
Open
MasterofJOKers wants to merge 1 commit intosebageek:masterfrom
Open
Conversation
We expose the functionality to run `CliMenu` in a background thread that the underlying `prompt_toolkit` library supports through a `run_in_thread` argument. This functionality can be necessary if we get called from a running event loop as the documentation of `in_thread` describes: :param in_thread: When true, run the application in a background thread, and block the current thread until the application terminates. This is useful if we need to be sure the application won't use the current event loop (asyncio does not support nested event loops). A new event loop will be created in this background thread, and that loop will also be closed when the background thread terminates. When this is used, it's especially important to make sure that all asyncio background tasks are managed through `get_appp().create_background_task()`, so that unfinished tasks are properly cancelled before the event loop is closed. This is used for instance in ptpython.
5789de0 to
ccba234
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We expose the functionality to run
CliMenuin a background thread that the underlyingprompt_toolkitlibrary supports through arun_in_threadargument. This functionality can be necessary if we get called from a running event loop as the documentation ofin_threaddescribes: