Issue
Im trying to run something basic for testing purposes and cant thru this issue. Not alot of wisdom here any ideas?
import sys
import asyncio
import signal
def ctrl_c():
print("hit!")
sys.exit(1)
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, ctrl_c)
loop.run_forever()
Im running this in IDLE python 3.6, and the traceback is:
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============== RESTART: C:\Users\benb\Desktop\reasyncio\loop.py ==============
Traceback (most recent call last):
File "C:\Users\benb\Desktop\reasyncio\loop.py", line 10, in <module>
loop.add_signal_handler(signal.SIGINT, ctrl_c)
File "C:\Users\benb\AppData\Local\Programs\Python\Python36\lib\asyncio\events.py", line 499, in add_signal_handler
raise NotImplementedError
NotImplementedError
>>>
Any tips help thanks
Solution
The error message tries to tell you that support for signals is not available on Windows. This is because Windows itself doesn't support signals as means of inter-process communication. What Windows calls signals can only trap certain low-level conditions that arise within the process, such as floating-point errors or user pressing Ctrl-C. See e.g. this post for details.
Answered By - user4815162342
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.