[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uwsgi
Subject:    [uWSGI] Close socket to nginx in wsgi application.
From:       turnaev.e () gmail ! com (Evgeny Turnaev)
Date:       2011-12-06 11:08:57
Message-ID: CAJ0L__Ee+4b5znkL=LXy+FRn3Uvd1D8ObKpDNVUPRQFP=CzUrA () mail ! gmail ! com
[Download RAW message or body]

Hello Roberto.
   Is there a way to close socket to nginx at the certain point in
  wsgi application ?

Use case:
     In my application i am doing some stats collect.
     Stats are: a few counters and timers and a few xpath on xml tries
     created during request processing.
     Stats processing (processing+ flushing results to logs) can take
10ms - 150ms

     The problem is: while iam doing stats uwsgi keeps socket to nginx open and
     nginx dont knows that there will be no more data ( i use yield in
wsgi app and no content-length header)
     and so nginx also keep socket to client browser open: so the
browser also thinks for 10-150ms
     there maybe more data coming.
     The page load time decreases and (maybe also some javascript
events fired late for 10- 150ms )
     I noticed that socket keep open untill wsgi app returns.

I don't want to move stats processing into separate process: it just
dont worth it. ( besides moving trees beetween processing or double
parsing.)

The thing i want is something like that:
-----
def application(environ, start_response):
      start_response()
      ...
      yield 'foo'
      ...
      environ['outsocket'].close()
      #process stats here
      stats code
-----

Any ideas how to workaround this?

Maybe i overlooked something obvious and simple, but i dont want to
solve this problem
with subprocessing in separate process because stats use a lot of
objects created during
request processing. (i understand that actually a process still will
be marked as "doing job and not free to process another incoming
request" - thats ok. it is actially now so and will not change. i just
want to speedup page load and dont wait for idle in browser.)




-- 
--------------------------------------------
??????? ??????? ??????????
+7 906 875 09 43
--------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic