Open okapies opened 1 year ago
This is really common. You cannot restart a Thread object. But the error message is is really hard to understand...we need to improve that..
Yes, but the async Client
is reusable instead. This is problematic especially when want to combine both versions. Can we fix to start the thread when connect
instead of __init__
?
Same is happening to me and I agree with your proposed expected behaviour.
I'd like to bump this, as we are currently migrating from opcua to opcua-asyncio using the wrapper functions.
We do reuse Client
s and this poses a problem for us.
Yes, but the async
Client
is reusable instead. This is problematic especially when want to combine both versions. Can we fix to start the thread whenconnect
instead of__init__
?
Hello everyone,
I have submitted a PR #1503, in which a new thread is started analogous to __init__
iff the ThreadLoop has stopped, so that the updated connect
method looks like this:
def connect(self) -> None:
if not self.tloop.is_alive():
self.tloop = ThreadLoop()
self.tloop.start()
self.close_tloop = True
self.tloop.post(self.aio_obj.connect())
Analogous for the Server's start
method.
This now ensures reusability of client and server, allowing a smoother migration, as mentioned by @aclementptw.
Describe the bug Calling
connect()
onsync.Client
afterdisconnect()
will raiseThreadLoopNotRunning
error.To Reproduce
Expected behavior (Re-)initialize
tloop
every time we callconnect()
.Version