waitress: can not see the 4 default threads

40 views
Skip to first unread message

Philip May

unread,
Jul 18, 2019, 3:54:19 PM7/18/19
to pylons-discuss
In the waitress documentation it is said that waitress starts 4 threads to handle the requests. When I start a waitress server to serve a flask rest API I can not see 4 threads being started (MacOS). Also when I output the ID of the threads (os.getpid()) I always get the same ID. What can be the reason here?
Thanks
Philip

Jonathan Vanasco

unread,
Jul 18, 2019, 5:21:16 PM7/18/19
to pylons-discuss
You could have configured the process to only use 1 thread. You could also be checking in the same thread, not a dispatched thread.  There are other possibilities too.

It's not really possible to answer a question like this without seeing code that reproduces this.

Michael Merickel

unread,
Jul 18, 2019, 6:52:23 PM7/18/19
to Pylons
processes != threads, it looks like you're thinking that waitress is using processes based on your suggestion that you think os.getpid() should return something different, or that you can't see them being started.

- Michael

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/a98dff6f-a3bb-48e3-a19f-7723ce729fb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

- Michael

Bert JW Regeer

unread,
Jul 19, 2019, 12:31:12 AM7/19/19
to Pylons Project
In very old versions of the Linux kernel (2.4.0 was when the change happened), threads would have their own pid because threads are implemented as processes...

Although I am guessing that is not what is being referred to here.

Philip May

unread,
Jul 19, 2019, 4:18:21 AM7/19/19
to pylons-discuss
Yes. I did confuse processes and threads...
Sorry for that.

Do you know why they use threads instead of tasks (processes)? I mean threads do not work in parallel (GIL-Problem) in python.
But the problem of a web container is IO bound in most cases I guess.

Am Freitag, 19. Juli 2019 00:52:23 UTC+2 schrieb Michael Merickel:
processes != threads, it looks like you're thinking that waitress is using processes based on your suggestion that you think os.getpid() should return something different, or that you can't see them being started.

- Michael

On Thu, Jul 18, 2019 at 2:54 PM Philip May <enia...@gmail.com> wrote:
In the waitress documentation it is said that waitress starts 4 threads to handle the requests. When I start a waitress server to serve a flask rest API I can not see 4 threads being started (MacOS). Also when I output the ID of the threads (os.getpid()) I always get the same ID. What can be the reason here?
Thanks
Philip

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-...@googlegroups.com.


--

- Michael

Jonathan Vanasco

unread,
Jul 19, 2019, 2:36:09 PM7/19/19
to pylons-discuss


On Thursday, July 18, 2019 at 6:52:23 PM UTC-4, Michael Merickel wrote:
processes != threads

ack! yes! sorry! 

Bert JW Regeer

unread,
Jul 19, 2019, 8:36:49 PM7/19/19
to Pylons Project

On Jul 19, 2019, at 02:18, Philip May <eniak...@gmail.com> wrote:

Yes. I did confuse processes and threads...
Sorry for that.

Do you know why they use threads instead of tasks (processes)?

Because in most cases IO waiting time (through asyncore) is going to be the overwhelming amount of time, and so threads are not active enough to cause contention between threads. There are other Python WSGI servers that may serve you better if you believe you are actually CPU bound and have issues with the GIL, such as gunicorn.

To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/527e7878-a32c-40a2-8f92-34706de9e541%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages