-
Notifications
You must be signed in to change notification settings - Fork 13
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
smtpd planned to be removed from stdlib #14
Comments
Thanks for pointing out! Removal is scheduled for 3.10 by the look of things, so this is still not too urgent. The recommended way to go is using aiosmtpd which requires python 3.5+. Until we decide to drop support for it, testing with 2.7 will probably continue being based on smtpd though. |
The SMTP server used by tests has currently been based on the smtpd system module. This module is deprecated though, as slated for removal in python 3.10, as indicated in #14. If we want to continue testing our mailing capabilities we therefore need to address this situation. This commit contains the necessary changes to keep supporting our SMTP test server using an external python package, aiosmtpd. The package is the recommended way of moving away from smtpd, and even had a useful guide on how to port code from one system to another. It also doesn't require us to keep track of the background thread running the server, which is a nice addition. Other than its API, it had one difference though: messages containing newline characters (\n) appear on the other side with a \r\n sequence, which didn't happen with smtpd. I haven't invested time to investigate why this is different between the two packages, but doing a small replace() call on the incoming data suffices for our purposes. The aiosmtpd package works only with python 3.6+, which is a narrow list compared to the one we want to support in NGAS. Because of this we therefore are maintaining both the smtpd- and the aiosmtpd-based versions of the SMTP servers, and only when smtpd is not available we switch to using the aiosmtpd-based solution. Finally, aiosmtpd requires a coroutine to be implemented. This is of course not possible in python 2.7 ("async def" doesn't parse). We avoid this by declaring an awaitable in a more "raw" format (i.e., returning an object with a __await__ method returning an iterator, etc...) Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
This is now implemented on the Local tests showed this is working, but sadly testing against python 3.10 in Travis is still not possible due to our dependencies not being easily available under python 3.10 (e.g., installing numpy fails at the moment). Once python 3.10 comes out officially, and wider package support is available, we can add a job in Travis. |
PEP 594 plans on removing smtpd from the standard library, it's probably worth working out what's needed to replace its usage within ngas.
The text was updated successfully, but these errors were encountered: