aio-libs / aiosmtpd

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

Controller throws a TimeoutError when binding a unspecified address #272

Open wevsty opened 3 years ago

wevsty commented 3 years ago

Controller throws a TimeoutError when binding a unspecified address. Affected versions: aiosmtpd (1.2.3-1.4.2) Example:

from aiosmtpd.controller import Controller

class CustomHandler:
    async def handle_DATA(self, server, session, envelope):
        return '250 OK'

if __name__ == '__main__':
    handler = CustomHandler()
    controller = Controller(handler, hostname='0.0.0.0', port=10025)
    controller.start()
    input('SMTP server running. Press Return to stop server and exit.')
    controller.stop()

Running this code will prompt an error

Traceback (most recent call last):
  File "C:\USER_PROGRAM\PyCharm\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\USER_PROGRAM\PyCharm\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/root/PycharmProjects/Projects/test.py", line 10, in <module>
    controller.start()
  File "C:\Users\root\PycharmProjects\Projects\venv\lib\site-packages\aiosmtpd\controller.py", line 231, in start
    raise TimeoutError(
TimeoutError: SMTP server started, but not responding within allotted time. This might happen if the system is too busy. Try increasing the `ready_timeout` parameter.

This is obviously a clear mistake. That needs to be fixed as soon as possible.

1756816846 commented 1 year ago

Why is there such a mistake

Traceback (most recent call last): File "C:/Users/Darkness/Desktop/crazy-email-recv-srv-master/dd.py", line 11, in controller.start() File "D:\python37\lib\site-packages\aiosmtpd\controller.py", line 315, in start "SMTP server started, but not responding within allotted time. " TimeoutError: SMTP server started, but not responding within allotted time. This might happen if the system is too busy. Try increasing the ready_timeout parameter.