Why is sanic spawning multiple threads when a single worker is launched?

1.1k Views Asked by At

I am launching a sanic app with a single worker in a docker container

root@2f69a2e79d16:/app# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 10:22 ?        00:00:00 python -m sanic server.app --host=0.0.0.0 --port=8000 --worker=1
root        12     0  0 10:23 pts/0    00:00:00 bash
root       336    12  0 10:24 pts/0    00:00:00 ps -ef
root@2f69a2e79d16:/app# 
root@2f69a2e79d16:/app# pstree -p 1
python(1)─┬─{python}(8)
          ├─{python}(9)
          ├─{python}(10)
          └─{python}(11)

Why is sanic launching multiple threads for a single worker ?

For one of our applications which uses sanic, I was seeing sanic launching around 21 threads ?

If sanic is lanuching threads for other management tasks, what is the count for the number of threads ? Are all the end requests served on a single thread ?

P.S: I don't see the code related to threads here

0

There are 0 best solutions below