AsyncPeriodicExecutor must reset CSOT contextvars before executing

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.13.1
    • Affects Version/s: 4.13
    • Component/s: async
    • None
    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      The asyncio.create_task API used by AsyncPeriodicExecutor handles ContextVars differently compared to the threads used by PeriodicExecutor.

      When a new thread is created, no existing ContextVar values are copied over. So if TIMEOUT=1 in the parent thread, TIMEOUT will be unset in the child.

      However, when a new asyncio.Task is created, a copy of each existing ContextVar is created in the new task. So if TIMEOUT=1 in the parent task, TIMEOUT=1 in the child task as well.

      This causes the SDAM monitor task to mistakenly apply timeouts such as timeoutMS to its operations. We need to reset all CSOT ContextVars on creation of our SDAM tasks.

            Assignee:
            Noah Stapp
            Reporter:
            Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: