Change in vdsm[ovirt-3.5]: jsonrpc: have simplejson as soft dependency

fromani at redhat.com fromani at redhat.com
Thu Nov 20 14:54:14 UTC 2014


Hello Piotr Kliczewski, Nir Soffer, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/35405

to review the following change.

Change subject: jsonrpc: have simplejson as soft dependency
......................................................................

jsonrpc: have simplejson as soft dependency

In commit ec58bca5cb18 we added dependency to
the external simplejson package to gain some speed,
especially on RHEL/Centos 6.x.

We discovered the hard way that python-simplejson
was moved out of the base system in RHEL/CentOS 7,
and put into the EPEL repository.
This is alone makes ec58bca5cb18 not good enough.

We still want to get the JSON codec speedups, so
to this patch
* moves the requires to RHEL/Centos 6.x only
* makes simplejson a soft dependency.

Change-Id: I11c05cff5b1cc3727653fa4ce210a76fcadf5628
Bug-Url: https://bugzilla.redhat.com/1155146
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/35354
Reviewed-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M lib/vdsm/compat.py
M lib/yajsonrpc/__init__.py
M vdsm.spec.in
3 files changed, 18 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/35405/1

diff --git a/lib/vdsm/compat.py b/lib/vdsm/compat.py
index 26c558e..9b5561e 100644
--- a/lib/vdsm/compat.py
+++ b/lib/vdsm/compat.py
@@ -24,3 +24,16 @@
 except ImportError:  # py3
     import pickle
     pickle  # yep, this is needed twice.
+
+try:
+    # on RHEL/Centos 6.x, the JSON module in the python standard
+    # library does not include significant speedups:
+    # stdlib is based on simplejson 1.9, speedups were added on 2.0.9.
+    # In general, speedups are first found on the
+    # simplejson package.
+    import simplejson as json
+    json  # make pyflakes happy
+except ImportError:
+    # no big deal, fallback to standard libary
+    import json
+    json  # yep, this is needed twice.
diff --git a/lib/yajsonrpc/__init__.py b/lib/yajsonrpc/__init__.py
index b3fd590..6ecdcfd 100644
--- a/lib/yajsonrpc/__init__.py
+++ b/lib/yajsonrpc/__init__.py
@@ -12,12 +12,14 @@
 # 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 json
 import logging
 from functools import partial
 from Queue import Queue
 from weakref import ref
 from threading import Lock, Event
+
+from vdsm.compat import json
+
 from vdsm.utils import traceback
 
 __all__ = ["tcpReactor"]
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 8bfbe20..96562bc 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -98,6 +98,7 @@
 BuildRequires: policycoreutils-python
 BuildRequires: m2crypto
 %if 0%{?rhel} == 6
+BuildRequires: python-simplejson >= 2.0.9
 BuildRequires: python-argparse
 BuildRequires: python-ordereddict
 %endif
@@ -306,6 +307,7 @@
 Obsoletes:      vdsm-api < 4.16
 %if 0%{?rhel} == 6
 Requires:       python-ordereddict
+Requires:       python-simplejson >= 2.0.9
 %endif
 
 %description jsonrpc


-- 
To view, visit http://gerrit.ovirt.org/35405
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I11c05cff5b1cc3727653fa4ce210a76fcadf5628
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>


More information about the vdsm-patches mailing list