Skip to content

Commit 8f85ee0

Browse files
committed
core: Add Router.self()
Returns a reference to the current context.
1 parent f20e0bb commit 8f85ee0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

mitogen/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,16 @@ def _on_broker_exit(self):
21542154
_, (_, func, _, _) = self._handle_map.popitem()
21552155
func(Message.dead(self.broker_exit_msg))
21562156

2157+
def self(self):
2158+
"""
2159+
Return a :class:`Context` referring to the current process.
2160+
"""
2161+
return self.context_class(
2162+
router=self,
2163+
context_id=mitogen.context_id,
2164+
name='self',
2165+
)
2166+
21572167
def context_by_id(self, context_id, via_id=None, create=True, name=None):
21582168
"""
21592169
Messy factory/lookup function to find a context by its ID, or construct

0 commit comments

Comments
 (0)