-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement coroutines to make value-callbacks async aware #144
base: master
Are you sure you want to change the base?
Implement coroutines to make value-callbacks async aware #144
Conversation
@swamper123 be carefull to not merge but use rebase to keep a somewhat clean pull request (ususally |
Sorry this took far too long from my side. Can you try to rebase and I will merge. |
@oroulet No worries, I had a small break as well. I'm already on it, but this may take another day. As well I'm still thinking about your concern of undefined behaviour. Do you know sth. about other OPC UA Stacks how they handle it? I storngly believe we are not the only one out there with such a problem. |
Undefined behavior? |
This PR is based on my (messy) old one, where you mentioned that race conditions may happen. |
Ok. I forgot that stuff.... Yes there is a potential issue here... Why do you need these methods async? |
My build up is a ("stupid-non OPC able") PLC and OPC UA server and I use a script to let them communicate (using asyncio). Instead of polling every xxx ms/s, I want to trigger a request process. This is where value_callback is used. If somebody wants to read the Value of a Node , the async request process starts. With a Coroutine I wouldn't have the problem, if the value is legit or not (because the Client receives a legit answer of the request process). I also got nodes which need a async func/method (between server and PLC) to even get a legit value. E.g. the temperature values in the PLC are in °C. Now I got some Nodes with Kelvin and Fahrenheit as well. If I want to read my Node with the °C value, I want to trigger the async value_callback, request, grab the values, calculate the stuff in Kelvin, Fahrenheit and Celsius and put the new values into their nodes as well. So my thought was, if it would be possible to add coros into the value_callback, I wouldn't have problems with my async communication Script, I could run even time intense async processes without (greater) performance loss incl. other coros timing out and it would be a good feature beside the sync value_callbacks as well. A problem could still be a race condition, in case a Node is deleted before an async value_callback may have finished. I don't know how asyncio & asyncua are handling cancelled Tasks in such a case. I posted 3 possible ideas in the last PR for a workaround:
What I don't know is, how asyncua may handle with such problems in gerneal. Like if somebody add race conditioning stuff in: opcua-asyncio/asyncua/server/address_space.py Line 697 in c878552
or in opcua-asyncio/asyncua/server/address_space.py Line 716 in c878552
|
a3edda2
to
a26508b
Compare
Well it seems that we have a problem with the python versions. Test works fine for me on Python 3.8, but seems to crash here on 3.6.7 in particular cases. |
@swamper123 discuss things here, so we do not needto look at differnt places to get overview. |
@oroulet So |
Remove? No but if we make them async we need to add an asyncio.Lock in address space so two tasks cannot modify address space at the same time |
I haven't noticed that they aren't async. But even if they aren't async, isn't it possible that someone throws a
|
Async stuff that was needed for that purpose
Async other server methods# Bitte geben Sie eine Commit-Beschreibung für Ihre Änderungen ein. Zeilen,
Async more stuff, where awaits were missing Fix __hash__ attributes
Async other server methods
This reverts commit 90dec1c.
Add awaits on all server.add_references and server.add_nodes # Conflicts: # asyncua/server/monitored_item_service.py
5a8e02e
to
e91dd37
Compare
c478fbd
to
9e1bdc8
Compare
9e1bdc8
to
b46d94f
Compare
8216984
to
125ef20
Compare
125ef20
to
169adf6
Compare
2a8f252
to
8610a40
Compare
09532d5
to
dde1aed
Compare
dde1aed
to
9ffa159
Compare
9ffa159
to
8a4dd3e
Compare
8a4dd3e
to
b33739f
Compare
Add missing await Remove blank lines Try triggering travis Try fix for test_tools Try fixing test_tools Remove typo Add brakets for correct coro response Add missing awaits and asyncs
89ddded
to
4503c7c
Compare
7a22f3e
to
48fa6ed
Compare
48fa6ed
to
8fa0a0b
Compare
8fa0a0b
to
1789fcb
Compare
1789fcb
to
358e2be
Compare
358e2be
to
f4bf325
Compare
make value_callback coroutine able
make changes methods and tests to make this able