FreeOpcUa / opcua-asyncio

OPC UA library for python >= 3.7
GNU Lesser General Public License v3.0
1.11k stars 358 forks source link

Configure ThreadLoop to be daemon #1555

Open eskildsf opened 8 months ago

eskildsf commented 8 months ago

Configuring a sync Client object and connecting it to an OPC-UA host will cause the calling script to hang on exit if disconnect() is not called. By setting the ThreadLoop to be a daemon resolves this issue.

oroulet commented 8 months ago

Is it safe? not correctly closing things is often a very bad ideas. But maybe in that particular case it is worth it... not sure

eskildsf commented 8 months ago

Hi @oroulet

I don't think I can say "yes" confidently. You probably have a better basis to make that call.

I will say though that it is quite useful for the Python session not to hang if you have an exception which causes a crash. That is probably the most relevant usecase since I do agree that in the best of all worlds the programmer would make the call to disconnect deliberately.

Br Eskild