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
Controller.start uses threading #160
Comments
@samuelcolvin thanks for the report! Do you have some docs or examples that we could reference? |
Take a look at aiohttp's run_app or its documentation on Runnings Applications. |
@samuelcolvin so if I don't misunderstood, you want to split out the thread-starting ability from Controller? Because currently all those code in Controller enables the event loop to run without blocking the main thread. If we take out the thread-creation part, then invoking run_forever() will block. And this will be a major, very impactful breaking behavioral change for existing users. EDIT: Rather than changing the existing Controller class, we can create a new class -- we can call it UnthreadedController or somesuch -- where the threading circuitry is taken out. So if user really wants to handle their own multithreading/multiprocessing management, they can use that class instead. Users already using existing Controller class don't have to do anything on their end. |
Why is the default behavior to run in a thread? Mirroring Samuel's request, having the ability to run it in the foreground without any threading would be useful. |
@nhoad One thing to realize is that The code for All the intelligence of the SMTP server happens in the |
I have a branch on my laptop, currently waiting for #247 to be merged first because it's based on that. |
Boy oh boy... apparently implementing unthreaded controllers is much more complex than I thought. Testing them properly is a whole 'nother level. |
If anyone wants to take a peek and/or kick the tires, be my guest: https://github.com/pepoluan/aiosmtpd/tree/unthreaded-controller |
The branch is about 99% complete, documentation also updated. Passes all tests on Windows and WSL (no time to test it on FreeBSD and OpenSUSE yet) Feel free to check it out @samuelcolvin @nhoad |
aiosmtpd/aiosmtpd/controller.py
Line 54 in 3ced778
It seems to be that
Controller.start
usingThreading
is not required and will lead to problems.Like the asyncio http server starting an SMTP server should not involve threading, but just
loop.run_forever()
.The text was updated successfully, but these errors were encountered: