Skip to content

await self._session_watchdog_task raises RuntimeError #1864

@dakotahorstman

Description

@dakotahorstman

Describe the bug

I'm not sure when UaProcessor.close is called or under what conditions, but await self._session_watchdog_task raises the following error:

[2025-09-04 16:40:27,385] [1] [WARNING] Session timed out after 25.0s of inactivity 
[2025-09-04 16:40:36,224] [1] [ERROR] Unexpected crash in BinaryServer._close_tasks 
Traceback (most recent call last):
  File "/opt/pysetup/.venv/lib/python3.12/site-packages/asyncua/server/binary_server_asyncio.py", line 182, in _close_tasks
    await task
  File "/opt/pysetup/.venv/lib/python3.12/site-packages/asyncua/server/uaprocessor.py", line 532, in close
    await self._session_watchdog_task
  File "/opt/pysetup/.venv/lib/python3.12/site-packages/asyncua/server/uaprocessor.py", line 547, in _session_watchdog_loop
    await self.close()
  File "/opt/pysetup/.venv/lib/python3.12/site-packages/asyncua/server/uaprocessor.py", line 532, in close
    await self._session_watchdog_task
RuntimeError: Task cannot await on itself: <Task pending name='Task-129415' coro=<UaProcessor._session_watchdog_loop() running at /opt/pysetup/.venv/lib/python3.12/site-packages/asyncua/server/uaprocessor.py:547>>

Whether the following observation is downstream of this, I'm not sure, but in my application, I've implemented an in-place update mechanism for my tags. It more or less drops and immediately replaces the targeted tag, preserving the node id. One of these operations ran ~15mins prior to this error, but that tag, after replacement, no longer triggered things like data change events. It is the only tag that more-or-less "stopped working".

The tag could be read and written to normally by my PLC, but my application never received data change events so the data was never recorded.

This error is somewhat rare, so some condition must exist for it to occur. Restarting the OPC server fixes the issue whenever it does occur, so I can continue doing that for now.

Let me know if there are any other details needed. More than willing to co-debug this if needed :)

Version

Python-Version:
3.12.11
opcua-asyncio Version (e.g. master branch, 0.9): 1.1.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions