def worker():
    print('serving at port', PORT)
httpd.serve_forever()

def my_service():
    time.sleep(3)
print('I am going down')
httpd.shutdown()
h = threading.Thread(name='httpd', target=worker)
t = threading.Thread(name='timer', target=my_service)
h.start()
t.start()
In python, how to get a UDPServer to shutdown itself?