[PATCH] ruby: make sure the database is closed

Felipe Contreras felipe.contreras at gmail.com
Mon Apr 23 08:07:23 PDT 2012


On Mon, Apr 23, 2012 at 5:04 PM, Ali Polatel <alip at exherbo.org> wrote:

> I'd rather not do this.
> Please read: http://comments.gmane.org/gmane.comp.lang.ruby.general/320324

OK, I've read this.. So?

The order in which Ruby's garbage-collector frees the database and
other objects is irrelevant, because with this patch we are not
manually freeing other objects, only the database.

Sure, it's _better_ if the user calls close(), even better if it's
inside an 'ensure', and even better if blocks are used (which I am
using in most cases), but that's not *required*.

The user might just do:

def foo
  db = Notmuch::Database.new($db_name, :mode => Notmuch::MODE_READ_WRITE)
end

That's perfectly fine in Ruby (although not ideal), since 'db' will
get garbage-collected. But nobody will be able to use the database
again until that process is killed.

You think that's correct?

-- 
Felipe Contreras


More information about the notmuch mailing list