You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. Can I use flask-profiler for api running in subthread? I tried it like the following. However I got ValueError: signal only works in main thread error. Can you please help me to solve it?
files
├── server.py
└── api.py
server.py
import time
import api
api_server = api.APIServer()
api_server.daemon = True
api_server.start()
while True:
time.sleep(1)
$ python3 server.py
* Serving Flask app "api" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/home/xxx/flask-profiler/api.py", line 35, in run
app.run(host="127.0.0.1", port=5000, threaded=True)
File "/home/xxx/.local/lib/python3.5/site-packages/flask/app.py", line 943, in run
run_simple(host, port, self, **options)
File "/home/xxx/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 812, in run_simple
reloader_type)
File "/home/xxx/.local/lib/python3.5/site-packages/werkzeug/_reloader.py", line 267, in run_with_reloader
signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
File "/usr/lib/python3.5/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
The text was updated successfully, but these errors were encountered:
Hi. Can I use flask-profiler for api running in subthread? I tried it like the following. However I got
ValueError: signal only works in main thread
error. Can you please help me to solve it?The text was updated successfully, but these errors were encountered: