mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-24 15:31:08 +00:00
ensure cache is setup
This commit is contained in:
parent
61014f791d
commit
097a53a539
|
@ -61,9 +61,12 @@ class Application(web.Application):
|
||||||
self['database'] = get_database(self.config)
|
self['database'] = get_database(self.config)
|
||||||
self['client'] = HttpClient()
|
self['client'] = HttpClient()
|
||||||
self['cache'] = get_cache(self)
|
self['cache'] = get_cache(self)
|
||||||
|
self['cache'].setup()
|
||||||
self['push_queue'] = multiprocessing.Queue()
|
self['push_queue'] = multiprocessing.Queue()
|
||||||
self['workers'] = []
|
self['workers'] = []
|
||||||
|
|
||||||
|
self.cache.setup()
|
||||||
|
|
||||||
self.on_response_prepare.append(handle_access_log)
|
self.on_response_prepare.append(handle_access_log)
|
||||||
self.on_cleanup.append(handle_cleanup)
|
self.on_cleanup.append(handle_cleanup)
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ class SqlCache(Cache):
|
||||||
|
|
||||||
|
|
||||||
def setup(self) -> None:
|
def setup(self) -> None:
|
||||||
if self._db.connected:
|
if self._db and self._db.connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._db = get_database(self.app.config)
|
self._db = get_database(self.app.config)
|
||||||
|
@ -243,6 +243,9 @@ class SqlCache(Cache):
|
||||||
|
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
|
if not self._db:
|
||||||
|
return
|
||||||
|
|
||||||
self._db.disconnect()
|
self._db.disconnect()
|
||||||
self._db = None
|
self._db = None
|
||||||
|
|
||||||
|
@ -351,5 +354,8 @@ class RedisCache(Cache):
|
||||||
|
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
|
if not self._rd:
|
||||||
|
return
|
||||||
|
|
||||||
self._rd.close()
|
self._rd.close()
|
||||||
self._rd = None
|
self._rd = None
|
||||||
|
|
Loading…
Reference in a new issue