Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
573a8a3f
Commit
573a8a3f
authored
Apr 15, 2022
by
Vladas Tamosaitis
Committed by
oroulet
Apr 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: parallel async datachange_notification calls
parent
cfe23db1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
asyncua/common/subscription.py
asyncua/common/subscription.py
+17
-12
No files found.
asyncua/common/subscription.py
View file @
573a8a3f
...
...
@@ -4,7 +4,7 @@ high level interface to subscriptions
import
asyncio
import
logging
import
collections.abc
from
typing
import
Union
,
List
,
Iterable
,
Optional
from
typing
import
Tuple
,
Union
,
List
,
Iterable
,
Optional
from
asyncua.common.ua_utils
import
copy_dataclass_attr
from
asyncua
import
ua
...
...
@@ -124,22 +124,27 @@ class Subscription:
results
[
0
].
check
()
async
def
_call_datachange
(
self
,
datachange
:
ua
.
DataChangeNotification
):
if
not
hasattr
(
self
.
_handler
,
"datachange_notification"
):
self
.
logger
.
error
(
"DataChange subscription created but handler has no datachange_notification method"
)
return
known_handles_args
:
List
[
Tuple
]
=
[]
for
item
in
datachange
.
MonitoredItems
:
if
item
.
ClientHandle
not
in
self
.
_monitored_items
:
self
.
logger
.
warning
(
"Received a notification for unknown handle: %s"
,
item
.
ClientHandle
)
continue
data
=
self
.
_monitored_items
[
item
.
ClientHandle
]
if
hasattr
(
self
.
_handler
,
"datachange_notification"
):
event_data
=
DataChangeNotif
(
data
,
item
)
try
:
if
asyncio
.
iscoroutinefunction
(
self
.
_handler
.
datachange_notification
)
:
await
self
.
_handler
.
datachange_notification
(
data
.
node
,
item
.
Value
.
Value
.
Value
,
event_data
)
else
:
self
.
_handler
.
datachange_notification
(
data
.
node
,
item
.
Value
.
Value
.
Value
,
event_data
)
except
Exception
:
self
.
logger
.
exception
(
"Exception calling data change handler"
)
else
:
self
.
logger
.
error
(
"DataChange subscription created but handler has no datachange_notification method"
)
event_data
=
DataChangeNotif
(
data
,
item
)
known_handles_args
.
append
((
data
.
node
,
item
.
Value
.
Value
.
Value
,
event_data
)
)
try
:
tasks
=
[
self
.
_handler
.
datachange_notification
(
*
args
)
for
args
in
known_handles_args
]
if
asyncio
.
iscoroutinefunction
(
self
.
_handler
.
datachange_notification
):
await
asyncio
.
gather
(
*
tasks
)
except
Exception
as
ex
:
self
.
logger
.
exception
(
"Exception calling data change handler. Error: %s"
,
ex
)
async
def
_call_event
(
self
,
eventlist
:
ua
.
EventNotificationList
):
for
event
in
eventlist
.
Events
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment