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
729ef892
Commit
729ef892
authored
Mar 16, 2022
by
oroulet
Committed by
oroulet
Mar 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve accuracy of subscription loop timing
parent
04a85e2c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
asyncua/server/internal_subscription.py
asyncua/server/internal_subscription.py
+8
-1
examples/client-example.py
examples/client-example.py
+3
-1
No files found.
asyncua/server/internal_subscription.py
View file @
729ef892
...
...
@@ -4,6 +4,7 @@ server side implementation of a subscription object
import
logging
import
asyncio
import
time
from
typing
import
Union
,
Iterable
,
Dict
,
List
from
asyncua
import
ua
...
...
@@ -72,9 +73,15 @@ class InternalSubscription:
"""
Start the publication loop running at the RevisedPublishingInterval.
"""
ts
=
time
.
time
()
period
=
self
.
data
.
RevisedPublishingInterval
/
1000.0
try
:
await
self
.
publish_results
()
while
True
:
await
asyncio
.
sleep
(
self
.
data
.
RevisedPublishingInterval
/
1000.0
)
next_ts
=
ts
+
period
sleep_time
=
next_ts
-
time
.
time
()
ts
=
next_ts
await
asyncio
.
sleep
(
max
(
sleep_time
,
0
))
await
self
.
publish_results
()
except
asyncio
.
CancelledError
:
self
.
logger
.
info
(
'exiting _subscription_loop for %s'
,
self
.
data
.
SubscriptionId
)
...
...
examples/client-example.py
View file @
729ef892
...
...
@@ -48,7 +48,7 @@ async def main():
# subscribing to a variable node
handler
=
SubHandler
()
sub
=
await
client
.
create_subscription
(
50
0
,
handler
)
sub
=
await
client
.
create_subscription
(
1
0
,
handler
)
handle
=
await
sub
.
subscribe_data_change
(
myvar
)
await
asyncio
.
sleep
(
0.1
)
...
...
@@ -60,6 +60,8 @@ async def main():
# calling a method on server
res
=
await
obj
.
call_method
(
"2:multiply"
,
3
,
"klk"
)
_logger
.
info
(
"method result is: %r"
,
res
)
while
True
:
await
asyncio
.
sleep
(
1
)
if
__name__
==
"__main__"
:
...
...
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