summaryrefslogtreecommitdiff
path: root/msgpack/_msgpack.pyx
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2011-01-29 23:23:56 +0900
committerINADA Naoki <songofacandy@gmail.com>2011-01-29 23:23:56 +0900
commit60d3ce3a180789ef5f57c22dd579c383ea7eed91 (patch)
treeebb9a1652dd1799d8bf1ec7972cd8cc7a35bcd59 /msgpack/_msgpack.pyx
parent3aaf5f5a7afb4d51e6384f87a3f70a4235b9afb5 (diff)
downloadmsgpack-python-60d3ce3a180789ef5f57c22dd579c383ea7eed91.tar.gz
python: Disable gc while deserializing.
Diffstat (limited to 'msgpack/_msgpack.pyx')
-rw-r--r--msgpack/_msgpack.pyx7
1 files changed, 7 insertions, 0 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx
index 9a6c232..e367444 100644
--- a/msgpack/_msgpack.pyx
+++ b/msgpack/_msgpack.pyx
@@ -9,6 +9,9 @@ cdef extern from "Python.h":
from libc.stdlib cimport *
from libc.string cimport *
+import gc
+_gc_disable = gc.disable
+_gc_enable = gc.enable
cdef extern from "pack.h":
struct msgpack_packer:
@@ -187,7 +190,9 @@ def unpackb(object packed, object object_hook=None, object list_hook=None, bint
if not PyCallable_Check(list_hook):
raise TypeError("list_hook must be a callable.")
ctx.user.list_hook = <PyObject*>list_hook
+ _gc_disable()
ret = template_execute(&ctx, buf, buf_len, &off)
+ _gc_enable()
if ret == 1:
return template_data(&ctx)
else:
@@ -326,7 +331,9 @@ cdef class Unpacker(object):
"""unpack one object"""
cdef int ret
while 1:
+ _gc_disable()
ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head)
+ _gc_enable()
if ret == 1:
o = template_data(&self.ctx)
template_init(&self.ctx)