provider.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:dd-trace-py 作者: DataDog 项目源码 文件源码
def active(self):
        """
        Returns the scoped ``Context`` for this execution flow. The ``Context``
        uses the ``Greenlet`` class as a carrier, and everytime a greenlet
        is created it receives the "parent" context.
        """
        current_g = gevent.getcurrent()
        ctx = getattr(current_g, CONTEXT_ATTR, None)
        if ctx is not None:
            # return the active Context for this greenlet (if any)
            return ctx

        # the Greenlet doesn't have a Context so it's created and attached
        # even to the main greenlet. This is required in Distributed Tracing
        # when a new arbitrary Context is provided.
        if current_g:
            ctx = Context()
            setattr(current_g, CONTEXT_ATTR, ctx)
            return ctx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号