Skip to content
Permalink
Browse files

core: Add Router.self()

Returns a reference to the current context.
  • Loading branch information
dw committed Dec 12, 2018
1 parent f20e0bb commit 8f85ee038e9f754e540a210894a79dab037d7244
Showing with 10 additions and 0 deletions.
  1. +10 −0 mitogen/core.py
@@ -2154,6 +2154,16 @@ def _on_broker_exit(self):
_, (_, 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

0 comments on commit 8f85ee0

Please sign in to comment.