wsgiserver thread count

已查看 207 次
跳至第一个未读帖子

Rita Morgan

未读,
2017年7月8日 07:32:202017/7/8
收件人 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

未读,
2017年7月10日 10:07:412017/7/10
收件人 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

未读,
2018年1月24日 06:50:592018/1/24
收件人 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

未读,
2018年1月24日 17:52:012018/1/24
收件人 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.
回复全部
回复作者
转发
0 个新帖子