Update.
This commit is contained in:
parent
483a63ede9
commit
c740de95f9
@ -14,6 +14,9 @@ from snek.view.threads import ThreadsView
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from ipaddress import ip_address
|
||||
import time
|
||||
import uuid
|
||||
|
||||
|
||||
import IP2Location
|
||||
from aiohttp import web
|
||||
@ -377,6 +380,8 @@ class Application(BaseApplication):
|
||||
|
||||
# @time_cache_async(60)
|
||||
async def render_template(self, template, request, context=None):
|
||||
start_time = time.perf_counter()
|
||||
|
||||
channels = []
|
||||
if not context:
|
||||
context = {}
|
||||
@ -437,10 +442,12 @@ class Application(BaseApplication):
|
||||
|
||||
self.jinja2_env.loader = self.original_loader
|
||||
|
||||
end_time = time.perf_counter()
|
||||
print(f"render_template took {end_time - start_time:.4f} seconds")
|
||||
|
||||
# rendered.text = whitelist_attributes(rendered.text)
|
||||
# rendered.headers['Content-Lenght'] = len(rendered.text)
|
||||
return rendered
|
||||
|
||||
async def static_handler(self, request):
|
||||
file_name = request.match_info.get("filename", "")
|
||||
|
||||
|
@ -40,6 +40,9 @@ class ChannelMessageService(BaseService):
|
||||
|
||||
async def maintenance(self):
|
||||
args = {}
|
||||
|
||||
|
||||
return
|
||||
for message in self.mapper.db["channel_message"].find():
|
||||
print(message)
|
||||
try:
|
||||
|
@ -14,7 +14,7 @@ class Cache:
|
||||
self.cache = {}
|
||||
self.max_items = max_items
|
||||
self.stats = {}
|
||||
self.enabled = True
|
||||
self.enabled = False
|
||||
self.lru = []
|
||||
self.version = ((42 + 420 + 1984 + 1990 + 10 + 6 + 71 + 3004 + 7245) ^ 1337) + 4
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
DEFAULT_LIMIT = 30
|
||||
import asyncio
|
||||
import typing
|
||||
|
||||
import time
|
||||
from snek.system.model import BaseModel
|
||||
|
||||
|
||||
@ -15,8 +15,6 @@ class BaseMapper:
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
self.default_limit = self.__class__.default_limit
|
||||
|
||||
@property
|
||||
def db(self):
|
||||
return self.app.db
|
||||
@ -27,6 +25,7 @@ class BaseMapper:
|
||||
|
||||
async def run_in_executor(self, func, *args, **kwargs):
|
||||
use_semaphore = kwargs.pop("use_semaphore", False)
|
||||
start_time = time.time()
|
||||
|
||||
def _execute():
|
||||
result = func(*args, **kwargs)
|
||||
@ -34,10 +33,9 @@ class BaseMapper:
|
||||
self.db.commit()
|
||||
return result
|
||||
|
||||
return _execute()
|
||||
#async with self.semaphore:
|
||||
# return await self.loop.run_in_executor(None, _execute)
|
||||
|
||||
result = _execute()
|
||||
async with self.semaphore:
|
||||
return _execute()
|
||||
|
||||
async def new(self):
|
||||
return self.model_class(mapper=self, app=self.app)
|
||||
|
Loading…
Reference in New Issue
Block a user