Exemple #1
0
    async def coro():
        with contextvars.context_binding(b=2):
            contextvars.merge(event)

            assert event == {
                "a": 1,
                "b": 2,
            }
            assert "containerlog_b" in contextvars._CTXVARS
            assert contextvars._CTXVARS["containerlog_b"].get() == 2
Exemple #2
0
 async def coro():
     contextvars.bind(a=5, b="foo")
     contextvars.bind(b="bar", c=False)
     contextvars.merge(event)
Exemple #3
0
 async def coro():
     contextvars.bind(a=5, c=True)
     contextvars.merge(event)
Exemple #4
0
 async def coro():
     contextvars.clear()
     contextvars.merge(event)
Exemple #5
0
 async def coro():
     contextvars.bind(a=5, b="foo", c=False)
     contextvars.clear()
     contextvars.merge(event)
Exemple #6
0
 async def coro():
     # unbinding does not explicitly remove the contextvar, it just sets it to
     # an ellipsis. to ensure the key was not previously set, add in some randomness.
     contextvars.unbind("%030x" % random.randrange(16**30))
     contextvars.merge(event)
Exemple #7
0
 async def coro():
     contextvars.bind(a=5)
     contextvars.unbind("a")
     contextvars.merge(event)
Exemple #8
0
 async def coro():
     contextvars.bind(a=5, b="foo", c=False)
     contextvars.unbind("b")
     contextvars.merge(event)
Exemple #9
0
 async def coro3():
     contextvars.bind(c=False)
     contextvars.merge(event)