mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-01 10:00:54 +00:00
Stop disable/enable gc.
json and pickle modules don't stop gc. It's a very dirty hack.
This commit is contained in:
parent
6aa4aead31
commit
235b928be7
1 changed files with 1 additions and 11 deletions
|
|
@ -13,10 +13,6 @@ from libc.string cimport *
|
|||
from libc.limits cimport *
|
||||
|
||||
|
||||
import gc
|
||||
_gc_disable = gc.disable
|
||||
_gc_enable = gc.enable
|
||||
|
||||
cdef extern from "pack.h":
|
||||
struct msgpack_packer:
|
||||
char* buf
|
||||
|
|
@ -242,11 +238,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
|
|||
if not PyCallable_Check(list_hook):
|
||||
raise TypeError("list_hook must be a callable.")
|
||||
ctx.user.list_hook = <PyObject*>list_hook
|
||||
_gc_disable()
|
||||
try:
|
||||
ret = template_execute(&ctx, buf, buf_len, &off)
|
||||
finally:
|
||||
_gc_enable()
|
||||
ret = template_execute(&ctx, buf, buf_len, &off)
|
||||
if ret == 1:
|
||||
return template_data(&ctx)
|
||||
else:
|
||||
|
|
@ -444,9 +436,7 @@ 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue