Variable definitions are stored in a child process of the sage server. They will be retained until one of the following processes stops:
- the child process
- the sage_server process
- the project process
Variables are therefore reset when any of the following happens:
- worksheet is restarted ("Restart" button at top of .sagews)
- Worksheet server is restarted ("Restart Sage Worksheet Server" button on project Settings and configuration page)
- project is restarted ("Restart project" dialogue on project Settings and configuration page)
If your project is on a free server, it will be stopped whenever the Google pre-emptible server instance restarts, typically once per 24 hours.
In any case, projects are stopped after some number of hours of non-interactive use, determined by the "Idle timeout" project setting on project Settings and configuration.