aio-libs / aiosmtpd

A reimplementation of the Python stdlib smtpd.py based on asyncio.
https://aiosmtpd.aio-libs.org
Apache License 2.0
312 stars 95 forks source link

Allow setting port=0 to use OS-assigned port. #381

Open alext opened 12 months ago

alext commented 12 months ago

What do these changes do?

Allow using port=0 when creating a Controller to use an OS-assigned port. Using port=0 is useful for ephemeral servers (eg for tests) where a given port can't necessarily be guaranteed to be available.

Are there changes in behavior for the user?

No changes to existing behaviour (when specifying a non-zero port, or leaving it at the default).

Related issue number

Closes: #276 (this implements the changes described in the comments on that issue)

Checklist

alext commented 12 months ago

Note: I've not been able to get the full test suite to run locally - it appears to hang within test_main.py. I've successfully run the test_server.py tests though...