Multi-Threaded api.connect() not working in Ubuntu Linux
cbeytas opened this issue · 0 comments
cbeytas commented
vncdotool v1.0.0, python 3.8.10, twisted 20.3.0 and 21.2.0
A simple VNC connection attempt works fine under Windows but when run on Linux (Ubuntu 20.04) it fails to establish a TCP connection. The connection starts, but never progresses. Seems to be a Twisted reactor issue.
In ThreadedVNCClientProxy
api.py line 77 it uses reactor.callWhenRunning
. This is not thread-safe. The reactor has already been started so it has the same effect of just calling factory_connect
directly from the main thread.
Wrapping it in reactor.callFromThread
fixed the issue for me:
reactor.callFromThread(reactor.callWhenRunning, factory_connect, self.factory, host, port, family)
import vncdotool.api
vnc = vncdotool.api.connect(server)
print(vnc.protocol)
None