sd-webui-stable-horde-worker
sd-webui-stable-horde-worker copied to clipboard
Execute in a separate thread
Description
The changes in 9edcf3bb7048115292107aba3e1e4ae18e1a25b7, 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
- [x] Bugfix
Please check the following items before submitting your pull request
- [x] I've checked that this isn't a duplicate pull request.
- [x] I've tested my changes with the latest SD-Webui version.
- [x] I've format my code with black:
black .
- [x] I've lint my code with flake8:
flake8 .
(The file has issues, but they're not my fault.) - [x] I've read the Contribution Guidelines
- [x] I've read the Code of Conduct
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?
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.