0

I have the below code:

from wsgiref import simple_server
import falcon

app = falcon.API(middleware=Auth())
msg = Something()
app.add_route('/hello', msg)     

httpd = simple_server.make_server(127.0.0.1, 8987, app)

m_process = Thread(target=httpd.serve_forever(poll_interval=0.5), name="m_process")
m_process.start()

s = Thread(target=httpd.shutdown(), name="s_process")
s.start()

In the logic of Something() class, I am incrementing or decrementing a counter that I have stored in a database based on some logic. I would like to call the s Thread based on a condition on the database. So in effect, I'm trying to shutdown the server. I used the explanation in http://code.nabla.net/doc/wsgiref/api/wsgiref/simple_server/wsgiref.simple_server.WSGIServer.html to do this. But it doesn't seem to kill the server. What am I doing wrong?

user1452759
  • 8,810
  • 15
  • 42
  • 58

1 Answers1

0

OKay I got the answer to my question. I was making a silly error in setting up the target of the m_process. The below is working

from wsgiref import simple_server
import falcon

app = falcon.API(middleware=Auth())
msg = Something()
app.add_route('/hello', msg)     

httpd = simple_server.make_server(127.0.0.1, 8987, app)

m_process = Thread(target=httpd.serve_forever, name="m_process")
m_process.start()

s = Thread(target=httpd.shutdown(), name="s_process")
s.start()
user1452759
  • 8,810
  • 15
  • 42
  • 58