avoid high cpu load for invalid range request
This commit is contained in:
parent
2ee8249cd5
commit
8c23d73bd3
2 changed files with 7 additions and 1 deletions
|
@ -9,13 +9,13 @@ from sqlalchemy.sql.expression import text
|
|||
from sqlalchemy import func
|
||||
|
||||
from oxtornado import actions
|
||||
import utils #utils must be imported before websocket to avoid loop
|
||||
from websocket import trigger_event
|
||||
import meta
|
||||
from . import models
|
||||
from . import query
|
||||
import settings
|
||||
import state
|
||||
import utils
|
||||
|
||||
from . import person_api
|
||||
from . import title_api
|
||||
|
|
|
@ -10,6 +10,9 @@ from . import models
|
|||
import settings
|
||||
import utils
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def parse(data):
|
||||
query = {}
|
||||
query['range'] = [0, 100]
|
||||
|
@ -18,6 +21,9 @@ def parse(data):
|
|||
for key in ('keys', 'group', 'list', 'range', 'sort', 'query'):
|
||||
if key in data:
|
||||
query[key] = data[key]
|
||||
if [r for r in query['range'] if not isinstance(r, int)]:
|
||||
logger.error('range must be 2 integers! got this: %s', query['range'])
|
||||
query['range'] = [0, 0]
|
||||
#print data
|
||||
query['qs'] = models.Item.find(data)
|
||||
if not 'group' in query:
|
||||
|
|
Loading…
Reference in a new issue