title: How to implement signal handling?
body: <p>I am trying to develop a TCP server which listens to a port and implements signals to make sure it shuts down after a preconfigured duration. I am using a Windows 10 machine and after execution I am getting an error. Here is my code:</p>
  <pre><code>import socket
  import signal
  import sys
  
  # create the signal handler
  def SigAlarmHandler(signal, frame):
      print(&quot;Received alarm... Shutting Down server...&quot;)
      sys.exit(0)
  
  
  signal.signal(signal.SIGALRM, SigAlarmHandler)
  signal.alarm(100)
  print(&quot;Starting work... waiting for quiting time...&quot;)
  while True:
      # define the target host and port
      host = '127.0.0.1'
      port = 444
  
      # define and create the server socket
      server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
      # bind the server to incoming client connection
      server.bind((host, port))
  
      # start the server listener
      server.listen(3)
  
      # establish connection with the client
      while True:
          client_socket, address = server.accept()
          print(&quot;connection received from %s&quot; % str(address))
          message = 'thank you for connecting to the server' + &quot;\r\n&quot;
          client_socket.send(message.encode('ascii'))
          client_socket.close()
      pass
  </code></pre>
  <p>Here is the error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/user/Desktop/pythons/tcpserver.py&quot;, line 19, in &lt;module&gt;
      signal.signal(signal.SIGALRM, SigAlarmHandler)
  AttributeError: module 'signal' has no attribute 'SIGALRM'
  </code></pre>