Francesco Romani has uploaded a new change for review.
Change subject: jsonrpc: deepcopy result in response
......................................................................
jsonrpc: deepcopy result in response
This patch fixes the RuntimeError below
which was (rarely) spotted in the wild:
Thread-281::ERROR::2014-10-28
16:31:20,971::__init__::244::root::(sendReply)
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/yajsonrpc/__init__.py",
line 242, in sendReply
encodedObjects.append(response.encode())
File "/usr/lib/python2.6/site-packages/yajsonrpc/__init__.py",
line 140, in encode
return json.dumps(res, 'utf-8')
File "/usr/lib64/python2.6/json/__init__.py", line 237, in dumps
**kw).encode(obj)
File "/usr/lib64/python2.6/json/encoder.py", line 367, in encode
chunks = list(self.iterencode(o))
File "/usr/lib64/python2.6/json/encoder.py", line 309, in
_iterencode
for chunk in self._iterencode_dict(o, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 275, in
_iterencode_dict
for chunk in self._iterencode(value, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 309, in
_iterencode
for chunk in self._iterencode_dict(o, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 275, in
_iterencode_dict
for chunk in self._iterencode(value, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 306, in
_iterencode
for chunk in self._iterencode_list(o, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 204, in
_iterencode_list
for chunk in self._iterencode(value, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 309, in
_iterencode
for chunk in self._iterencode_dict(o, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 247, in
_iterencode_dict
for key, value in items:
RuntimeError: dictionary changed size during iteration
Change-Id: I5d3214bce52e410428eeda5ad604fab06b27753c
Relates-To:
https://bugzilla.redhat.com/1143968
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/yajsonrpc/__init__.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/34580/1
diff --git a/lib/yajsonrpc/__init__.py b/lib/yajsonrpc/__init__.py
index b3fd590..9c93960 100644
--- a/lib/yajsonrpc/__init__.py
+++ b/lib/yajsonrpc/__init__.py
@@ -12,6 +12,7 @@
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import copy
import json
import logging
from functools import partial
@@ -119,7 +120,7 @@
class JsonRpcResponse(object):
def __init__(self, result=None, error=None, reqId=None):
- self.result = result
+ self.result = copy.deepcopy(result)
self.error = error
self.id = reqId
--
To view, visit
http://gerrit.ovirt.org/34580
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d3214bce52e410428eeda5ad604fab06b27753c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>