Re: [web2py] cron Too many open files regression?

2011-07-07 Thread ron_m
The code running this is in gluon/newcron.py
From your stack trace you are using hard cron which is a class at line 44. 
It runs launch once a minute
This runs crondance which puts a wrapper on the tasks that should be run 
adding web2py run line parameters if * or ** is at the beginning of the 
command. The crondance function then uses class cronlauncher which in turn 
uses subprocess.Popen to launch the task.

If you have web2py like processes building up do these processes have other 
processes with the web2py process pid listed as the parent process. You 
should be able to do a ps -ef pick the pid of one of the web2py processes 
and run another ps -ef with grep pid to filter. The process started with the 
Popen will have to close the pipe usually by exiting to release the thread 
from cronlauncher.

Do these cron tasks run okay if you just launch them from the shell. That is 
a good test to determine that there are no problems outside the cron 
environment.

Do you use a SQLite database? This database performs a global lock to 
protect from multiple access.

Do the cron tasks take more than their scheduling interval to complete. The 
launcher will run another copy without regard for an existing copy still 
running.

Do any of the tasks have locking code such as a file lock that other tasks 
depend on gaining access to. Two file locks shared by two processes with 
crossed access, one process locks a then b, other locks b then a will 
deadlock if the timing is right.

Do any tasks read stdin, the subprocess.Popen call opens the stdin of the 
process to the launcher but will never write to it so a read on stdin would 
hang preventing exit.

I hope this is some help, looks like a difficult one to find but likely 
something fairly simple to fix once you find it.

Could you post your crontab file, it would be a start of something to look 
at.




Re: [web2py] cron Too many open files regression?

2011-07-06 Thread John Duddy
None that I know of. The processes that accumulate have the same
arguments as the main web2py process (as shown by ps -ef) so it's like
a fork with no exec.

On Wednesday, July 6, 2011, ron_m ron.mco...@gmail.com wrote:
 Maybe one possibility is if your code has classes with a __del__ method in 
 them, Massimo would have better perspective on if this is a possibility. If a 
 class with this method is involved in a circular reference the garbage 
 collector cannot clean it up because of uncertainty of execution of the 
 __del__ method. This was discussed a lot on the group a few months back. I 
 believe exec also has to be involved. Do a search for __del__ in the group to 
 see what was said. There were also some tools mentioned in those threads that 
 help with tracking down this sort of problem.

 I find in Python as soon as a file variable binding produced by open goes out 
 of scope it is closed, you don't have to specifically call close on it. 
 Normally objects are dropped as soon as the reference count reaches 0. The 
 garbage collector was added to clean up the circular referenced objects that 
 will never get a count down to 0 without some outside help. It searches the 
 heap looking for objects that have no references except other objects also in 
 the garbage and marks those as candidates to clean out. The fact that these 
 file objects are piling up means something is holding the file reference 
 which also cannot be cleaned up.

 Are you running on Linux? If so the /proc/pid_of_web2py/fd directory using ls 
 -l will show you what files by name are open to the process which might 
 provide some clues to which part of your code.


-- 
John Duddy
jdu...@gmail.com


[web2py] cron Too many open files regression?

2011-07-05 Thread John Duddy
I'm getting the following stack trace in my console after leaving my
app running overnight. We use cron for several tasks.

I saw the below thread, which indicated that the issue has been
resolved:

http://groups.google.com/group/web2py/browse_thread/thread/e788b0783e8fc758/6a210abb2898763d?lnk=raot

Has there been a regression?

Here's the stack trace. Thanks!

Traceback (most recent call last):
  File /usr/local/lib/python2.7/threading.py, line 552, in
__bootstrap_inner
self.run()
  File /root/web2py/gluon/newcron.py, line 63, in run
s.run()
  File /usr/local/lib/python2.7/sched.py, line 117, in run
  File /root/web2py/gluon/newcron.py, line 55, in launch
crondance(self.path, 'hard', startup = False)
  File /root/web2py/gluon/newcron.py, line 234, in crondance
cronmaster = token.acquire(startup=startup)
  File /root/web2py/gluon/newcron.py, line 101, in acquire
self.master = open(self.path,'rb+')
IOError: [Errno 24] Too many open files: '/root/web2py/applications/
admin/cron/cron.master'