radiocosmology / alpenhorn

Alpenhorn is a service for managing an archive of scientific data.
MIT License
2 stars 1 forks source link

fix(db): Don't initialise peewee DB in every thread #167

Closed ketiltrout closed 1 year ago

ketiltrout commented 1 year ago

peewee already handles threadsafety of the inherently not threadsafe MySQL connection, so there's no need for us to second guess it.

This changes the way the DB framework is initialised: all initialisation happens in the main thread. peewee is smart enough to open per-thread connections to the database on demand in the worker threadds.

As a result, the default DB code (which CHIME doesn't use) is now reported to be threadsafe, which is nice.