remove asyncio_main()

This commit is contained in:
Son NK 2021-03-15 19:49:14 +01:00
parent 98264b14bc
commit 7811f06fc1
1 changed files with 0 additions and 34 deletions

View File

@ -1806,40 +1806,6 @@ def main(port: int):
time.sleep(2)
def asyncio_main(port: int):
"""
Main entrypoint using asyncio directly without passing by aiosmtpd Controller
"""
if LOAD_PGP_EMAIL_HANDLER:
LOG.warning("LOAD PGP keys")
app = create_app()
with app.app_context():
load_pgp_public_keys()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
lock = asyncio.Lock()
handler = MailHandler(lock)
def factory():
return aiosmtpd.smtp.SMTP(handler, enable_SMTPUTF8=True)
server = loop.run_until_complete(
loop.create_server(factory, host="0.0.0.0", port=port)
)
try:
loop.run_forever()
except KeyboardInterrupt:
pass
# Close the server
LOG.info("Close SMTP server")
server.close()
loop.run_until_complete(server.wait_closed())
loop.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(