Sanic app not working on windows

I am trying to run the basic sanic app on windows 10. But it is just stuck there showing this warning
sanic tried to use loop.add_signal_handler but it is not implemented on this platform

sanic - 19.12.2
python - 3.7.6 (anaconda env)

sanic help

Did you install via?

pip install sanic

@SpootDev Installed the way you mentioned. Now I am getting this error:

from aiofiles import open as open_async # type: ignore
ImportError: cannot import name 'open' from 'aiofiles' (unknown location)

Update: aiofiles didn’t get installed properly. I copied the files manually to site-packages.
Now my error is:

import hstspreload
ModuleNotFoundError: No module named 'hstspreload'

I had to manually download and copy aiofiles, hpack, hyperframe,h11, rfc3986, hstspreload to the site-packages folder. But back to the original problem:

sanic tried to use loop.add_signal_handler but it is not implemented on this platform

A number of Windows bugs including this one is fixed in Sanic git master, to be released as 20.3 soon (I hope). I suppose that the fixes will need backporting to 19.12LTS as well but Windows support on that is low priority and I’m afraid it will take much longer.

If you are in a hurry, you can always

pip install git+

Please let me know ASAP if you find any issues with that so that we might still fix them prior to next release.

1 Like

Now it’s working.

Also if this helps :-
It runs from anaconda prompt fine, but to run from spyder I had to downdrade to tornado 4.5.3.

I had tornado 6.0.4 installed and got this error while running from spyder:-

if __name__ == "__main__":"", port=5000)

[2020-04-02 09:40:17 +0600] [11960] [INFO] Goin' Fast @
[2020-04-02 09:40:17 +0600] [11960] [ERROR] Unable to start server
Traceback (most recent call last):
  File "C:\Users\Raihan\Anaconda3\envs\e37\lib\site-packages\sanic\", line 921, in serve
http_server = loop.run_until_complete(server_coroutine)
  File "C:\Users\Raihan\Anaconda3\envs\e37\lib\asyncio\", line 563, in run_until_complete
  File "C:\Users\Raihan\Anaconda3\envs\e37\lib\asyncio\", line 526, in _check_runnung
'Cannot run the event loop while another loop is running')
RuntimeError: Cannot run the event loop while another loop is running
[2020-04-02 09:40:17 +0600] [11960] [INFO] Server Stopped

spyder version: 4.1.1

You cannot use within IPython environment (like in Spyder’s integrated console). Choose in Spyder Run settings to start your app in a stand-alone terminal. Alternatively, you may use something like

await app.create_server(return_asyncio_server=True)

… if you must use ipython/spyder integrated console.

1 Like

Thank you, I will try it

Hi @Tronic. I am having another problem with sanic-restful can you please look at it?