diff --git a/mitogen/core.py b/mitogen/core.py index a55fe93a..be44c800 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -2154,6 +2154,16 @@ class Router(object): _, (_, func, _, _) = self._handle_map.popitem() func(Message.dead(self.broker_exit_msg)) + def self(self): + """ + Return a :class:`Context` referring to the current process. + """ + return self.context_class( + router=self, + context_id=mitogen.context_id, + name='self', + ) + def context_by_id(self, context_id, via_id=None, create=True, name=None): """ Messy factory/lookup function to find a context by its ID, or construct