Registry: use a pool of registries to avoid having too many open files

The same file might have been held open many times (by using lots
of distinct butlers, from pickling lots of data references), causing
a "too many open files error".  Instead, cache the registries and
re-use.

Thanks to Yousuke Utsumi for finding this bug, and Michitaro Koike
for providing a fix.
Merge branch 'tickets/HSC-1009'
Registry: hold registry cache for a single thread only (HSC-1035)

We destroy the connection cache when we discover that we're in
a new thread, to avoid using a SQLite connection from a thread
other than which it was created in (resulting in: "ProgrammingError:
SQLite objects created in a thread can only be used in that same
thread.").  multiprocessing runs a thread within each process
(only one at a time), and different iterations in a process appear
to use different threads.

This is not attempting to be thread-safe (this is inherently NOT
thread-safe --- there is no locking or thread-specific data), but
to support multiprocessing, as SQLite (and possibly others) will not
use a connection created in a different thread.

Could have chosen to hold the cache of connections indexed on the
thread identifier, but that means several connections for the same
database could be open at the same time, which defeats the purpose
of the cache (or, at least, makes it less effective).
Merge branch 'tickets/HSC-1035': Exception in butler due to sqlite thread problem