def callWithContext(self, newContext, func, *args, **kw):
        """
        Call C{func(*args, **kw)} such that the contents of C{newContext} will
        be available for it to retrieve using L{getContext}.

        @param newContext: A C{dict} of data to push onto the context for the
            duration of the call to C{func}.

        @param func: A callable which will be called.

        @param *args: Any additional positional arguments to pass to C{func}.

        @param **kw: Any additional keyword arguments to pass to C{func}.

        @return: Whatever is returned by C{func}

        @raise: Whatever is raised by C{func}.
        """
        self.contexts.append(newContext)
        try:
            return func(*args,**kw)
        finally:
            self.contexts.pop()

        Call C{func(*args, **kw)} such that the contents of C{newContext} will
        be available for it to retrieve using L{getContext}.

        @param newContext: A C{dict} of data to push onto the context for the
            duration of the call to C{func}.

        @param func: A callable which will be called.

        @param *args: Any additional positional arguments to pass to C{func}.

        @param **kw: Any additional keyword arguments to pass to C{func}.

        @return: Whatever is returned by C{func}

        @raise: Whatever is raised by C{func}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/context.py