0

I'm currently working with this OPC UA implementation: https://github.com/FreeOpcUa/

My problem is that I cant stop a running server. Even in all examples a python shell stays open after I call server.stop().

Do you guys know how I can stop the server and kill the thread? Thanks!

2 Answers2

0

i don't know anything about opcua, so maybe i am wrong, but you can't kill a thread in python. You need to wait until every thread has gracefully finished. In order to stop your threads, they need to check regularly for a stopping flag. For example have a look here: Is there any way to kill a Thread in Python?

olisch
  • 960
  • 6
  • 11
0

I'm using freeopcua too and server.stop() indeed tends to go wrong. in the examples

I think in the examples it's the embed causing the issues. It's the embed that is causing this. I don't know why they added it or yes... I do know to keep the server running as otherwise the python script would end.

I myself do this by waiting for user input on server side if the user enters then the server will stop

server.start()
input("enter to stop...\n")
server.stop()

this is on my server side It's not the cleanest way but for certain the embed is what's causing the issue for you guys too. And there are many potential solutions to this keep the server running without the embed() function

davy gillebert
  • 307
  • 1
  • 11
  • Note that this is if I run the server as independent script if I started a server in my test files for example I can just call server.stop() there without issue as after my tests are done I can close the server – davy gillebert Aug 31 '17 at 13:51