I would write a management command and let a cron job fire off to run it. See this for how to write management commands: http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
Then your cron job can look something like this: */5 * * * * python /path/to/manage.py copyfromftp >> /dev/null 2>&1 But running this as a separate command you'll make sure than for each run python will reuse memory it has freed. You might also want to write it so that the management command only does a limited about of photos in one batch and instead run the management command often. On 1 Aug, 22:50, TiNo <[email protected]> wrote: > Hi, > I am working on an image gallery. I am making use of django-imagekit. My > site is hosted at a VPS, with 80 MBs of memory. I use NginX with fastcgi. > > What I am trying to accomplish is the following: > 1. A logged-in user goes to an /upload page, where information about the ftp > server is listed > 2. The user uploads his pictures through ftp (sometimes more than 100), and > clicks 'done' on the page. > 3. Images get imported, their EXIF data gets added to the database and they > are resized (to about 1024x800) > 4. Original images are moved to an 'originals' folder, and stored for some > time. > > I got everything covered, except from step 3. As I don't have a lot of > memory, I can't afford to load all the images in the main script. The django > fastcgi instances then quickly use about 100MBs together, for quite some > time. > > So I will do this in a separate python script. Then some questions: > - It would be nice to open the uploaded file as an PIL image, resize it, and > save it to the final destination, therefore saving an extra open() call. It > is probably possible to do this in a subclassed ImageField, but I can't > really get my head around these FileFields with the FieldFile classes. So > what method would I have to override to do this? > - What would be the best way to start a separate python script? And is there > any way to communicate between de fastcgi script and the import script? Say > pass that we are at image 25 of 100? > > Thanks, > > TiNo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

