This commit is contained in:
parent
f2ff036455
commit
9bb53e266f
@ -1,10 +1,11 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import base64
|
||||
import json
|
||||
import pathlib
|
||||
import time
|
||||
import uuid
|
||||
import asyncio
|
||||
|
||||
import aiohttp_jinja2
|
||||
import dataset
|
||||
import jinja2
|
||||
@ -162,8 +163,8 @@ class BaseApplication(RPCApplication):
|
||||
|
||||
|
||||
class WebDbApplication(BaseApplication):
|
||||
|
||||
@property
|
||||
|
||||
@property
|
||||
def loop(self):
|
||||
return asyncio.get_event_loop()
|
||||
|
||||
@ -175,7 +176,9 @@ class WebDbApplication(BaseApplication):
|
||||
):
|
||||
self.db_web = db_web
|
||||
self.db_path = db_path
|
||||
self.db = db or dataset.connect(self.db_path)
|
||||
self.db = db or dataset.connect(
|
||||
self.db_path, engine_kwargs={"connect_args": {"check_same_thread": False}}
|
||||
)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
if not self.db_web:
|
||||
@ -249,7 +252,7 @@ class WebDbApplication(BaseApplication):
|
||||
return self.db["kv"].upsert({"key": key, "value": value}, ["key"])
|
||||
|
||||
async def get(self, key, default=None):
|
||||
return await self.run_in_executor(self.sget,key, default)
|
||||
return await self.run_in_executor(self.sget, key, default)
|
||||
|
||||
def sget(self, key, default=None):
|
||||
record = self.db["kv"].find_one(key=key)
|
||||
|
Loading…
Reference in New Issue
Block a user