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

Execute in a separate thread #110

Merged
merged 1 commit into from
May 21, 2024
Merged

Conversation

Maeyanie
Copy link
Contributor

@Maeyanie Maeyanie commented Jun 21, 2023

Description

The changes in 9edcf3b, at least for my setup (Conda, Python 3.10, Win10) resulted in horde.run() running async, but still in the main thread. This mostly worked, but caused the whole WebUI to block while horde.run() wasn't sleeping.

I tried a couple of things, and this is what ended up working best for me, with a lot of the functions in the loop being async and it not being possible to use await in a non-async function. Moving the thread function somewhere else might be more elegant, I don't know your code well enough to know where would be best to put it though.

Type of changes

  • Bugfix

Please check the following items before submitting your pull request

  • I've checked that this isn't a duplicate pull request.
  • I've tested my changes with the latest SD-Webui version.
  • I've format my code with black: black .
  • I've lint my code with flake8: flake8 . (The file has issues, but they're not my fault.)
  • I've read the Contribution Guidelines
  • I've read the Code of Conduct

Just running async was still blocking the WebUI while a generation was running.
@MaikoTan
Copy link
Member

MaikoTan commented Jul 7, 2023

Looks good. But I can only see there is a .start() method, so when does the thread terminate?

By the way, we are trying to replace aiohttp and all asyncio things into synchronous API with requests in #102 , would it solve the block issue without touching thread?

@Maeyanie
Copy link
Contributor Author

Maeyanie commented Jul 7, 2023

The thread would terminate when the process is terminated, effectively the same as before.

I'm not sure if that would help or not, I'm more of a C++ programmer than a Python one. My guess would be no, due to the nature of how event queues work, but it would be better to test it to find out for sure.

It would probably change the best approach to using a thread, though, so if that's coming reasonably soon it may be better not to merge this and wait to see how things turn out.

Copy link
Contributor

@gabriel20xx gabriel20xx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@MaikoTan MaikoTan merged commit 5b02b24 into sdwebui-w-horde:master May 21, 2024
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.

3 participants