YoRyan / mailrise

An SMTP gateway for Apprise notifications.
https://mailrise.xyz
MIT License
898 stars 39 forks source link

Fix Windows compatibility #73

Closed brian9206 closed 1 year ago

brian9206 commented 1 year ago

If you try to run mailrise on Windows, you will get this error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Brian\AppData\Roaming\Python\Python311\Scripts\mailrise.exe\__main__.py", line 7, in <module>
  File "C:\Users\Brian\AppData\Roaming\Python\Python311\site-packages\mailrise\skeleton.py", line 170, in run
    main(sys.argv[1:])
  File "C:\Users\Brian\AppData\Roaming\Python\Python311\site-packages\mailrise\skeleton.py", line 159, in main
    eloop.add_signal_handler(sig, clean_exit)
  File "C:\Python311\Lib\asyncio\events.py", line 574, in add_signal_handler
    raise NotImplementedError
NotImplementedError

The root cause of this issue is loop.add_signal_handler is not available on Windows according to the Python Event Loop documentation

Therefore, I changed it to call signal.signal on Windows. It may not be the best solution, but at least it can now run on Windows.

YoRyan commented 1 year ago

Thanks for the report! I develop Mailrise solely for Linux and Docker and don't make a habit of testing for other operating systems.

I've opted to just catch NotImplementedError and continue. It's nice to be able to gracefully stop the event loop, but it's not essential to do so.