Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Wamp serialization error fix: huge unsigned int (#4236)
Browse files Browse the repository at this point in the history
* Wamp serialization error fix: huge unsigned int

* deep bigint to string conversion definition for collections

* lint

* all integers converted to string
  • Loading branch information
mdtanrikulu committed May 27, 2019
1 parent 9dc463d commit 471110f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 14 additions & 0 deletions golem/rpc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,17 @@ def predicate(member):
continue
mapping[uri] = method
return mapping


def int_to_string(item):
# Deeply convert all integer elements of collections to string
if isinstance(item, list):
for k, v in enumerate(item):
item[k] = int_to_string(v)
elif isinstance(item, dict):
for k, v in item.items():
item[k] = int_to_string(v)
elif isinstance(item, int):
item = str(item)

return item
14 changes: 7 additions & 7 deletions golem/task/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _validate_task_dict(client, task_dict) -> None:
subtasks_count=subtasks_count,
optimize_total=False,
use_frames=options.get('frame_count', 1) > 1,
frames=[None]*options.get('frame_count', 1),
frames=[None] * options.get('frame_count', 1),
)
if computed_subtasks != subtasks_count:
raise ValueError(
Expand Down Expand Up @@ -347,7 +347,7 @@ def _start_task(client, task, resource_server_result):

@defer.inlineCallbacks
def enqueue_new_task(client, task, force=False) \
-> typing.Generator[defer.Deferred, typing.Any, taskbase.Task]:
-> typing.Generator[defer.Deferred, typing.Any, taskbase.Task]:
"""Feed a fresh Task to all golem subsystems"""
validate_client(client)
task_id = task.header.task_id
Expand Down Expand Up @@ -401,7 +401,8 @@ def _create_task_error(e, _self, task_dict, **_kwargs) \
logger.error("Cannot create task %r: %s", task_dict, e)

if hasattr(e, 'to_dict'):
return None, e.to_dict()
temp_dict = rpc_utils.int_to_string(e.to_dict())
return None, temp_dict

return None, str(e)

Expand Down Expand Up @@ -729,10 +730,9 @@ def get_estimated_cost(

@rpc_utils.expose('comp.task.rendering.task_fragments')
def get_fragments(self, task_id: str) -> \
typing.Tuple[
typing.Optional[typing.Dict[int, typing.List[typing.Dict]]],
typing.Optional[str]
]:
typing.Tuple[
typing.Optional[typing.Dict[int, typing.List[typing.Dict]]],
typing.Optional[str]]:
"""
Returns the task fragments for a given rendering task. A single task
fragment is a collection of subtasks referring to the same, common part
Expand Down

0 comments on commit 471110f

Please sign in to comment.