wsgiserver thread count

207 views
Skip to first unread message

Rita Morgan

unread,
Jul 8, 2017, 7:32:20 AM7/8/17
to gevent: coroutine-based Python network library
is it possible to see total number of threads or queue size of the wsgi server? Trying to determine the average response time from a server poiint of view

Jason Madden

unread,
Jul 10, 2017, 10:07:41 AM7/10/17
to gev...@googlegroups.com

> On Jul 8, 2017, at 06:14, Rita Morgan <rmorg...@gmail.com> wrote:
>
> is it possible to see total number of threads or queue size of the wsgi server? Trying to determine the average response time from a server poiint of view

If you provide a `Pool` instance[1] (bounded or unbounded) to the `spawn` argument of the server[2] you can see how many requests are being serviced by asking for the Pool's `len`.

By default, the server doesn't place any bound on the number of outstanding requests, so the only "queue" is the socket backlog. (I suppose you could consider some internal details of the event loop---the way in which greenlets are "scheduled" to run---as a sort of a queue, because they happen one at a time. You can get a rough idea about that by the implementation detail get_hub().loop._callbacks.)

If you use a bounded Pool, then requests could "queue" waiting to be run. There's not a public API to determine how many such requests are waiting, but you could probably figure it out from implementation details (specifically, Pool._semaphore._links).

Jason

[1] http://www.gevent.org/gevent.pool.html#gevent.pool.Pool
[2] http://www.gevent.org/gevent.baseserver.html

Rita Morgan

unread,
Jan 24, 2018, 6:50:59 AM1/24/18
to gevent: coroutine-based Python network library
Do you have a example on how to this?

I am struggling to implement something like this.

Jason Madden

unread,
Jan 24, 2018, 5:52:01 PM1/24/18
to gevent: coroutine-based Python network library
Sorry, no, I can’t provide an example or more guidance beyond the code and links I already sent at this time. Perhaps someone else can.
Reply all
Reply to author
Forward
0 new messages