the system version of the msgpack library might be a performance-wise
better choice than ryu/contrib one because of cython.
on the other hand, the cython version of the code has known bugs.
use the system msgpack library only if it seems to work without the bug.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/lib/rpc.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ryu/lib/rpc.py b/ryu/lib/rpc.py
index 57a35ba..6b8a0ab 100644
--- a/ryu/lib/rpc.py
+++ b/ryu/lib/rpc.py
@@ -19,6 +19,18 @@
 # msgpack-rpc
 # http://wiki.msgpack.org/display/MSGPACK/RPC+specification
 
+import sys
+import ryu.contrib
+try:
+    _m = ryu.contrib.import_system('msgpack')
+    # https://github.com/msgpack/msgpack-python/pull/64
+    assert isinstance(_m.unpackb(_m.packb(0x100000000)), int)
+    msgpack = _m
+except:
+    # XXX
+    sys.modules.pop('msgpack', None)
+    sys.modules.pop('msgpack._packer', None)
+    sys.modules.pop('msgpack._unpacker', None)
 import msgpack
 
 
-- 
1.8.0.1


------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to