Re: [modwsgi] How to be notified when client is gone away

2012-07-21 Thread lvqier
Many thanks! I will not perform the detection rely on this way.

On Friday, July 20, 2012 2:09:31 PM UTC+8, Graham Dumpleton wrote:

 There isn't really a way. You can read past discussions on this in the 
 group archives about points where closure may be detected. One such 
 discussion is: 

 https://groups.google.com/d/msg/modwsgi/jr2ayp0xesk/QtINxMi_KUAJ 

 Graham 

 On 19 July 2012 22:55, lvqier wrote: 
  I am confused with the following code (test.py), which is a wsgi 
  application: 
  
  #!/usr/bin/env python 
  
  from subprocess import Popen, PIPE 
  import os 
  
  cwd = os.path.dirname(os.path.abspath(__file__)) 
  exe = os.path.join(cwd, 'wait.py') 
  
  def application(environ, start_response): 
  process_args = ['python', exe, cwd, '10'] 
  process = Popen(process_args, stdout = PIPE, stderr = PIPE) 
  process.wait() 
  start_response('200 OK', [('Content-Type', 'text/plain'),]) 
  return ['finished'] 
  
  
  where wait.py is: 
  
   #!/usr/bin/env python 
  
  import pyinotify 
  
  class iNotifyEventHandler(pyinotify.ProcessEvent): 
  def process_IN_CLOSE_WRITE(self, event): 
  fp = event.pathname 
  print 'File created: %s' % fp 
  
  def watch(folder): 
  watch_manager = pyinotify.WatchManager() 
  watch_manager.add_watch(folder, 
  pyinotify.EventsCodes.ALL_FLAGS['IN_CLOSE_WRITE'], rec = True, auto_add 
 = 
  True) 
  handler = iNotifyEventHandler() 
  watch_inotify_inst = pyinotify.Notifier(watch_manager, handler) 
  return watch_inotify_inst 
  
  if __name__ == '__main__': 
  import sys 
  if len(sys.argv) != 3: 
  print 'Usage: %s folder timeout' % sys.argv[0] 
  exit(1) 
  folder = sys.argv[1] 
  timeout = int(sys.argv[2]) 
  notifier = watch(folder) 
  notifier.process_events() 
  if notifier.check_events(timeout = timeout): 
  notifier.read_events() 
  notifier.process_events() 
  
  
  There comes the problem: 
  
  When web clients access the wsgi application, the wsgi forks wait.py as 
  subprocess and wait it to be finished. But when the subprocess takes too 
  long to return, the client may go away before the wsgi application 
 became 
  ready to response. In this situation, I want the subprocess to be 
 terminated 
  as soon as the client is missing. What should I do? 
  
  If the wsgi application could catch a signal when the client is gone 
 away, a 
  signal could be sent to the subprocess indicating termination. But I 
 have no 
  idea which signal to be handled in the wsgi application. 
  
  Appreciate for your help. 
  
  -- 
  You received this message because you are subscribed to the Google 
 Groups 
  modwsgi group. 
  To view this discussion on the web visit 
  https://groups.google.com/d/msg/modwsgi/-/ZE5FKEa3d0kJ. 
  To post to this group, send email to modwsgi@googlegroups.com. 
  To unsubscribe from this group, send email to 
  modwsgi+unsubscr...@googlegroups.com. 
  For more options, visit this group at 
  http://groups.google.com/group/modwsgi?hl=en. 


-- 
You received this message because you are subscribed to the Google Groups 
modwsgi group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/modwsgi/-/ofabizUdGZEJ.
To post to this group, send email to modwsgi@googlegroups.com.
To unsubscribe from this group, send email to 
modwsgi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.



Re: [modwsgi] Re: mod_wsgi and mod_ruid2

2012-07-21 Thread slech
Graham,
Thank you very much for help! Now it is working perfect!

 WSGIDaemonProcess moin user=www-moin group=www-moin home=/web/moin/ 
 processes=5 threads=10 maximum-requests=1000 umask=0007



On Friday, July 20, 2012 8:51:00 PM UTC+3, Graham Dumpleton wrote:

 Use: 

 WSGIDaemonProcess moin user=www-moin group=www-moin home=/tmp 
 processes=5 threads=10 maximum-requests=1000 umask=0007 

 That is, add home=/tmp argument. 

 This will get rid of complaint about not being able to change home 
 directory. 

 Graham


-- 
You received this message because you are subscribed to the Google Groups 
modwsgi group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/modwsgi/-/TrMPaSolOE4J.
To post to this group, send email to modwsgi@googlegroups.com.
To unsubscribe from this group, send email to 
modwsgi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.