Commit 42ae54c3 authored by Jason Madden's avatar Jason Madden

More safely handle getting a callback from libuv once we're destroyed.

parent be372d26
...@@ -189,7 +189,7 @@ class loop(AbstractLoop): ...@@ -189,7 +189,7 @@ class loop(AbstractLoop):
self.SIGNAL_CHECK_INTERVAL_MS) self.SIGNAL_CHECK_INTERVAL_MS)
libuv.uv_unref(self._signal_idle) libuv.uv_unref(self._signal_idle)
def _run_callbacks(self): def __check_and_die(self):
if not self.ptr: if not self.ptr:
# We've been destroyed during the middle of self.run(). # We've been destroyed during the middle of self.run().
# This method is being called into from C, and it's not # This method is being called into from C, and it's not
...@@ -198,6 +198,8 @@ class loop(AbstractLoop): ...@@ -198,6 +198,8 @@ class loop(AbstractLoop):
# handle is invalid.") So switch to the parent greenlet. # handle is invalid.") So switch to the parent greenlet.
getcurrent().parent.throw(LoopExit('Destroyed during run')) getcurrent().parent.throw(LoopExit('Destroyed during run'))
def _run_callbacks(self):
self.__check_and_die()
# Manually handle fork watchers. # Manually handle fork watchers.
curpid = os.getpid() curpid = os.getpid()
if curpid != self._pid: if curpid != self._pid:
...@@ -574,6 +576,7 @@ class loop(AbstractLoop): ...@@ -574,6 +576,7 @@ class loop(AbstractLoop):
return result return result
def now(self): def now(self):
self.__check_and_die()
# libuv's now is expressed as an integer number of # libuv's now is expressed as an integer number of
# milliseconds, so to get it compatible with time.time units # milliseconds, so to get it compatible with time.time units
# that this method is supposed to return, we have to divide by 1000.0 # that this method is supposed to return, we have to divide by 1000.0
...@@ -581,6 +584,7 @@ class loop(AbstractLoop): ...@@ -581,6 +584,7 @@ class loop(AbstractLoop):
return now / 1000.0 return now / 1000.0
def update_now(self): def update_now(self):
self.__check_and_die()
libuv.uv_update_time(self.ptr) libuv.uv_update_time(self.ptr)
def fileno(self): def fileno(self):
......
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