greenlet.py 文件源码

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

项目:dd-trace-py 作者: DataDog 项目源码 文件源码
def __init__(self, *args, **kwargs):
        # get the current Context if available
        current_g = gevent.getcurrent()
        ctx = getattr(current_g, CONTEXT_ATTR, None)

        # create the Greenlet as usual
        super(TracedGreenlet, self).__init__(*args, **kwargs)

        # the context is always available made exception of the main greenlet
        if ctx:
            # create a new context that inherits the current active span
            # TODO: a better API for Context, should get the tuple at once
            new_ctx = Context(
                trace_id=ctx._parent_trace_id,
                span_id=ctx._parent_span_id,
                sampled=ctx._sampled,
            )
            new_ctx._current_span = ctx._current_span
            setattr(self, CONTEXT_ATTR, new_ctx)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号