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

smtpd planned to be removed from stdlib #14

Closed
aragilar opened this issue Oct 17, 2019 · 2 comments
Closed

smtpd planned to be removed from stdlib #14

aragilar opened this issue Oct 17, 2019 · 2 comments

Comments

@aragilar
Copy link
Contributor

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.

@rtobar
Copy link
Contributor

rtobar commented Oct 17, 2019

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.

rtobar added a commit that referenced this issue Jan 11, 2021
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>
@rtobar
Copy link
Contributor

rtobar commented Jan 12, 2021

This is now implemented on the master branch. The code still tries to import smtpd, but when that's not possible it then requires aiosmtpd to be present, and the SMTP server used for testing is implemented in terms of the latter package.

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.

@rtobar rtobar closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants