Created
October 5, 2019 03:28
-
-
Save masayuki038/f9f9396d32320adc0af8cb882bc26ad2 to your computer and use it in GitHub Desktop.
Getting thread dump of each process (master / workers) of uWSGI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import os | |
import json | |
import threading | |
from flask import Flask, jsonify | |
from uwsgidecorators import postfork | |
import pystuck | |
pystuck.run_server(unix_socket='/tmp/utd-master') | |
i = 0 | |
app = Flask(__name__) | |
@postfork | |
def worker_init(): | |
pystuck.run_server(unix_socket=f'/tmp/utd-{os.getpid()}') | |
def process(): | |
while True: | |
try: | |
global i | |
i += 1 | |
print(f"i: {i}") | |
except Exception as err: | |
print(f"err: {err}") | |
sleep(5) | |
th = threading.Thread(target=process, name='test-thread', daemon=False) | |
th.start() | |
@app.route('/hello') | |
def hello_world(): | |
sleep(5) | |
return jsonify({'message': f'Hello World, {i}, {threading.currentThread().ident}'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment