fix API thread safe issues of txt2img and img2img #14421
Merged
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.
Description
TL;DR:
Function
ui.create_ui
andself.init_default_script_args
are not thread-safe.It causes thread-safety issues of API
txt2img
andimg2img
.To ensure the API is thread-safe, I move the code to init
Steps to reproduce the thread-safety issues
1. Run webui with the following command
2. Run the following python script
In most cases you will see the error on the
terminal
which running webui.If not encounter the error,
ctrl+c
cancel the webui then repeat the above steps again until the error appearsFix issue #10884
Checklist: