On Jul 28, 2010, at 11:57 PM, mdipierro wrote:
> I modified the expire_sessions.py in trunk and added a
> try:...execept... If the problem was that a file was locked and the
> cron task got stuck, it may be solved now. Can you test it?
In this patch:
@@ -6,8 +6,14 @@
now=time.time()
for file in os.listdir(path):
filename=os.path.join(path,file)
- t=os.stat(filename)[stat.ST_MTIME]
- if os.path.isfile(filename) and now-t>EXPIRATION_MINUTES*60 \
- and file.startswith(('1','2','3','4','5','6','7','8','9')):
- os.unlink(filename)
-
+ try:
+ t=os.stat(filename)[stat.ST_MTIME]
+ if os.path.isfile(filename) and now-t>EXPIRATION_MINUTES*60 \
+ and file.startswith(('1','2','3','4','5','6','7','8','9')):
+ try:
+ os.unlink(filename)
+ except:
+ print 'failure to unlink', filename
+ except:
+ print 'failure to stat', filename
+
you might want to print "failed to unlink", and the errno or its string
expansion would be handy
But a question: where does this print end up? What's stdout in this situation?