mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-14 03:27:59 +00:00
25 lines
435 B
Python
25 lines
435 B
Python
|
import asyncio
|
||
|
import logging
|
||
|
import simplejson as json
|
||
|
|
||
|
|
||
|
from . import CONFIG
|
||
|
|
||
|
|
||
|
try:
|
||
|
with open(CONFIG['db']) as f:
|
||
|
DATABASE = json.load(f)
|
||
|
except:
|
||
|
logging.info('No database was found, making a new one.')
|
||
|
DATABASE = {}
|
||
|
|
||
|
|
||
|
async def database_save():
|
||
|
while True:
|
||
|
with open(CONFIG['db'], 'w') as f:
|
||
|
json.dump(DATABASE, f)
|
||
|
await asyncio.sleep(30)
|
||
|
|
||
|
|
||
|
asyncio.ensure_future(database_save())
|