[Tutor] Too many open files -- how to copy a folder?
Chad Crabtree
flaxeater at yahoo.com
Fri Oct 29 18:14:01 CEST 2004
Matej Cepl wrote:
>>>>import email,email.Utils
>>>>import mailbox
>>>>box = mailbox.Maildir("/home/matej/WP/trash/")
>>>>date = email.Utils.parsedate_tz
>>>>import time
>>>>dlist = list(time.localtime())
>>>>dlist[1] -= 3
>>>>archdate = tuple(dlist)
>>>>alist = [x for x in box if date(x['date'])<archdate]
>>>>
>>>>
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.3/mailbox.py", line 246, in next
>IOError: [Errno 24] Too many open files:
>'/home/matej/WP/trash/cur/1098844013.6284.XKuCF:2,S'
>
>
Perhaps instead of using a list comprehension you should use a
generator, if you wnat a generator expression then you need to
upgrade
to 2.4 however let's try and get the jist of this
def genBox(box):
for x in box:
if date(x['date'])<archdate:
yield x
I have not tested this but I think this would call only one file at a
time.
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com
More information about the Tutor
mailing list