Commit 0813d0e9 authored by Denis Bilenko's avatar Denis Bilenko

Hub.destroy(): by default, keep default loop alone

parent 169285f4
...@@ -416,8 +416,7 @@ class Hub(greenlet): ...@@ -416,8 +416,7 @@ class Hub(greenlet):
event.unlink(switch) event.unlink(switch)
return False return False
def destroy(self): def destroy(self, destroy_loop=None):
# this function would be useful after fork / before exec
global _threadlocal global _threadlocal
if self._resolver is not None: if self._resolver is not None:
self._resolver.close() self._resolver.close()
...@@ -425,8 +424,11 @@ class Hub(greenlet): ...@@ -425,8 +424,11 @@ class Hub(greenlet):
if self._threadpool is not None: if self._threadpool is not None:
self._threadpool.close() self._threadpool.close()
del self._threadpool del self._threadpool
self.loop.destroy() if destroy_loop is None:
del self.loop destroy_loop = not self.loop.default
if destroy_loop:
self.loop.destroy()
self.loop = None
if getattr(_threadlocal, 'hub', None) is self: if getattr(_threadlocal, 'hub', None) is self:
del _threadlocal.hub del _threadlocal.hub
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment