From ff7fb00569155bc53b00b65682c3812680c46ff9 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 29 Apr 2018 10:11:13 +0100 Subject: [PATCH] parent: return latch to wait() caller to allow graceful timeout --- docs/api.rst | 5 +++++ mitogen/parent.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 37640464..17b1b38d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -917,6 +917,11 @@ Context Class :param bool wait: If :py:data:`True`, block the calling thread until the context has completely terminated. + :returns: + If `wait` is :data:`False`, returns a :class:`mitogen.core.Latch` + whose :meth:`get() ` method returns + :data:`None` when shutdown completes. The `timeout` parameter may + be used to implement graceful timeouts. .. method:: call_async (fn, \*args, \*\*kwargs) diff --git a/mitogen/parent.py b/mitogen/parent.py index 497ccd0a..2203ef9c 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -806,7 +806,8 @@ class Context(mitogen.core.Context): if wait: latch.get() - return latch + else: + return latch class RouteMonitor(object):