On 16 říj, 06:28, Mike Hansen <[email protected]> wrote: > How do _you_ detect when the session is over? Your code needs to be > responsible for detecting when the session is over and deleting the > PNGs.
You can also use sufficiently random and long names in temp directory and in cron daemon clean this directory each hour (for example, each hour delete files older than 30 minutes). But remember that if you have to start sage, build picture and so on, it takes some time. The user sitting at the computer is impatient and can resend from many times in short time. I am developer of Mathematical assistant on Web ( http://user.mendelu.cz/marik/maw/index.php?lang=en ) and there are users which send the same request up to ten times in one second! >From this reason I suggest you * run the external program with time limit which kill everything after some time (I use Maxima and Maxima may hang sometime, I have not enough experiences with Sage in this direction, but it is a good idea to use this for every programm) * refuse computation, if the server load is bigger than .... (your constant) The latter (for example) is also not sufficient - user can send really many requests when the load is small and can generate really huge load. For example, in MAW we refuse computations if load is bigger than 5 and last week somebody generated load 130 ! :) This means, server is not able to respond for a long time and may swap too much and crash. So I hope that your server is virtual server or a machine which is not used for other things. You can also use <img src='http://skript?data'/> on your generated html page, where where script is another script which * makes temporary directory of file with picture * sends the picture to the browser * cleans the temporary stuff * still run some script which checks (once a day) that old files are deleted This is used for example http://user.mendelu.cz/marik/maw/index.php?lang=en&form=graf - you can see that html page appers soon and image later. If you click the image or link for PDF once and wait, you get your animation. If you click more times, you get an error and have to return to original form. Sources are at http://mathassistant.cvs.sourceforge.net/viewvc/mathassistant/maw/graf/graf.php?revision=1.38&view=markup and you may be interested in lines 531-539 Hope this helps Robert --~--~---------~--~----~------------~-------~--~----~ 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/sage-support URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
