Thursday, June 7, 2012

Sage Shutdown

I'm starting to learn how to use the Sage mathematics system, an incredibly comprehensive compilation of open-source mathematics software integrated with a unified scripting language (a dialect of Python) and a nifty browser-based notebook interface. So far, so good, with one minor but annoying exception. I invariably use the notebook interface, which launches a local web server (in Python, of course). When I exit all open notebooks, click the "sign out" link and zap the browser window(s), a bunch of processes spawned by Sage (including the server) remain running in the background.

You wouldn't know it to see my house or office, but I'm a bit of a "neat freak" when it comes to processes running on my PC. I'd like a clean shut down, but strangely enough there is no link in the browser interface that will shut down all Sage-related processes. One of those processes is the Sage "cleaner daemon", which theoretically watches for shutdown and tidies up ... except it doesn't, and there seems to be no way for me to tell it that I want Sage to shut down.

There is an answer, posted by William Stein (originator of the Sage project) himself. It's just not entirely satisfying. Following his advice, I created a two line shell script that looks up the PID of the cleaner process and kills it, which triggers a cascade that kills all other Sage-related processes. It works as advertised. I parked it in my $HOME/.sage directory (so that it will survive any upgrades to Sage) and added it to Mint's menu. Presumably the same thing, with minor modifications, works on Windows and OS/X.

All this strikes me as a bit user-unfriendly, though. It cannot be that hard to make the same thing available from the notebook interface, at least if you are logged in as the administrator. (In a multi-user environment, which does not apply to me, you would not want a generic user to have the ability to kill the server.) I'm not the only one wishing for this, either.

No comments:

Post a Comment

If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on OR-Exchange.