Pollenware/patio — pull request #38 by mbenedettini (2012-08-07 15:28:37+00:00)
Title: CachePlugin: lazy hive initialization

This patch allows the hive not to be initialized until strictly needed: i.e. a Model instance actually needs it.

What motivated it is that this simple node.js script:

var patio = require('patio');

won't ever return to shell, as the hive is never killed. It's also annoying when trying to use patio from within Jake (https://github.com/mde/jake/) and your jakefile's execution never returns to shell.

The problem lies in the cleanup interval set on hive/lib/hive.js:50 :

this.__cleanupInterval = setInterval(comb.hitch(this, this._checkValues), this.__checkInterval);

That timer is never stopped and therefore doesn't allow that simple script to gracefully exit.

This pull request only solves the problem if you are not using the cache plugin (my case). It is still your responsibility to clear the interval if you are using the plugin and want your application to successfully stop.