Manually handle deallocation of some objects for the benefit of p3.7
Python 3.7 seems to have trouble dealocating objects in a timely fashion. We rely on this, because the c++ destructors need to run before the kj event loop is closed. Hence, we do it manually.
This commit is contained in:
@@ -2039,6 +2039,11 @@ cdef class _DynamicCapabilityClient:
|
|||||||
cdef C_DynamicCapability.Client thisptr
|
cdef C_DynamicCapability.Client thisptr
|
||||||
cdef public object _parent, _cached_schema
|
cdef public object _parent, _cached_schema
|
||||||
|
|
||||||
|
def __dealloc__(self):
|
||||||
|
# Needed to make Python 3.7 happy, which seems to have trouble deallocating stack objects
|
||||||
|
# appropriately
|
||||||
|
self.thisptr = C_DynamicCapability.Client()
|
||||||
|
|
||||||
cdef _init(self, C_DynamicCapability.Client other, object parent):
|
cdef _init(self, C_DynamicCapability.Client other, object parent):
|
||||||
self.thisptr = other
|
self.thisptr = other
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
@@ -2194,6 +2199,11 @@ cdef class TwoPartyClient:
|
|||||||
cdef Own[RpcSystem] thisptr
|
cdef Own[RpcSystem] thisptr
|
||||||
cdef _TwoPartyVatNetwork _network
|
cdef _TwoPartyVatNetwork _network
|
||||||
|
|
||||||
|
def __dealloc__(self):
|
||||||
|
# Needed to make Python 3.7 happy, which seems to have trouble deallocating stack objects
|
||||||
|
# appropriately
|
||||||
|
self.thisptr = Own[RpcSystem]()
|
||||||
|
|
||||||
def __init__(self, socket=None, traversal_limit_in_words=None, nesting_limit=None):
|
def __init__(self, socket=None, traversal_limit_in_words=None, nesting_limit=None):
|
||||||
|
|
||||||
cdef schema_cpp.ReaderOptions opts = make_reader_opts(traversal_limit_in_words, nesting_limit)
|
cdef schema_cpp.ReaderOptions opts = make_reader_opts(traversal_limit_in_words, nesting_limit)
|
||||||
@@ -2224,6 +2234,11 @@ cdef class TwoPartyServer:
|
|||||||
cdef Own[RpcSystem] thisptr
|
cdef Own[RpcSystem] thisptr
|
||||||
cdef _TwoPartyVatNetwork _network
|
cdef _TwoPartyVatNetwork _network
|
||||||
|
|
||||||
|
def __dealloc__(self):
|
||||||
|
# Needed to make Python 3.7 happy, which seems to have trouble deallocating stack objects
|
||||||
|
# appropriately
|
||||||
|
self.thisptr = Own[RpcSystem]()
|
||||||
|
|
||||||
def __init__(self, socket=None, bootstrap=None, traversal_limit_in_words=None, nesting_limit=None):
|
def __init__(self, socket=None, bootstrap=None, traversal_limit_in_words=None, nesting_limit=None):
|
||||||
if not bootstrap:
|
if not bootstrap:
|
||||||
raise KjException("You must provide a bootstrap interface to a server constructor.")
|
raise KjException("You must provide a bootstrap interface to a server constructor.")
|
||||||
@@ -2250,6 +2265,11 @@ cdef class _AsyncIoStream:
|
|||||||
cdef Own[AsyncIoStream] thisptr
|
cdef Own[AsyncIoStream] thisptr
|
||||||
cdef _EventLoop _event_loop # We hold a pointer to the event loop here, to ensure it remains alive
|
cdef _EventLoop _event_loop # We hold a pointer to the event loop here, to ensure it remains alive
|
||||||
|
|
||||||
|
def __dealloc__(self):
|
||||||
|
# Needed to make Python 3.7 happy, which seems to have trouble deallocating stack objects
|
||||||
|
# appropriately
|
||||||
|
self.thisptr = Own[AsyncIoStream]()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def create_connection(host = None, port = None, **kwargs):
|
async def create_connection(host = None, port = None, **kwargs):
|
||||||
"""Create a TCP connection.
|
"""Create a TCP connection.
|
||||||
|
|||||||
Reference in New Issue
Block a user