Skip to content
Snippets Groups Projects
Commit 2e48c911 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'decimal_serialization_fix' into 'develop'

Fixed internal error during processing response containing a Decimal object...

See merge request !39
parents fcb55894 fffdb424
No related branches found
No related tags found
4 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!135Enable postgres monitoring on CI server,!39Fixed internal error during processing response containing a Decimal object...
......@@ -11,7 +11,7 @@ toolz = "*"
maya = "*"
ujson = "*"
prettytable = "*"
jsonrpcserver = "*"
jsonrpcserver = "4.1.3+8f3437a"
aiohttp = "*"
aiopg = "*"
"psycopg2-binary" = "*"
......
......@@ -11,6 +11,8 @@ from aiohttp import web
from jsonrpcserver.methods import Methods
from jsonrpcserver import async_dispatch as dispatch
import simplejson
from hive.server.condenser_api import methods as condenser_api
from hive.server.condenser_api.tags import get_trending_tags as condenser_api_get_trending_tags
from hive.server.condenser_api.get_state import get_state as condenser_api_get_state
......@@ -35,6 +37,12 @@ from hive.server.db import Db
# pylint: disable=too-many-lines
def decimal_serialize(obj):
return simplejson.dumps(obj=obj, use_decimal=True)
def decimal_deserialize(s):
return simplejson.loads(s=s, use_decimal=True)
async def db_head_state(context):
"""Status/health check."""
db = context['db']
......@@ -268,10 +276,10 @@ def run_server(conf):
"""Handles all hive jsonrpc API requests."""
request = await request.text()
# debug=True refs https://github.com/bcb/jsonrpcserver/issues/71
response = await dispatch(request, methods=methods, debug=True, context=app)
response = await dispatch(request, methods=methods, debug=True, context=app, serialize=decimal_serialize, deserialize=decimal_deserialize)
if response.wanted:
headers = {'Access-Control-Allow-Origin': '*'}
return web.json_response(response.deserialized(), status=200, headers=headers)
return web.json_response(response.deserialized(), status=200, headers=headers, dumps=decimal_serialize)
return web.Response()
if conf.get('sync_to_s3'):
......
......@@ -14,7 +14,8 @@ funcy==1.14
-e git+git@gitlab.syncad.com:hive/hivemind.git@ba54fc07c08c2fd08b37475c9a15d61c64e380c9#egg=hivemind
humanize==2.4.0
idna==2.9
jsonrpcserver==4.0.1
-e git+https://github.com/bcb/jsonrpcserver.git@8f3437a19b6d1a8f600ee2c9b112116c85f17827#egg=jsonrpcserver-4.1.3+8f3437a
simplejson
jsonschema==2.6.0
Mako==1.1.2
Markdown==2.4.1
......
......@@ -26,10 +26,14 @@ setup(
packages=find_packages(exclude=['scripts']),
setup_requires=['pytest-runner', 'setuptools-git-version'],
tests_require=tests_require,
dependency_links=[
'https://github.com/bcb/jsonrpcserver/tarball/8f3437a19b6d1a8f600ee2c9b112116c85f17827#egg=jsonrpcserver-4.1.3+8f3437a'
],
install_requires=[
#'aiopg==0.16.0',
'aiopg @ https://github.com/aio-libs/aiopg/tarball/862fff97e4ae465333451a4af2a838bfaa3dd0bc',
'jsonrpcserver==4.0.1',
'jsonrpcserver @ https://github.com/bcb/jsonrpcserver/tarball/8f3437a19b6d1a8f600ee2c9b112116c85f17827#egg=jsonrpcserver'
'simplejson',
'aiohttp',
'certifi',
'sqlalchemy',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment