def __setup_connection_timer(self, force=False):
"""
Sets up the connection timer that handles monitoring of the live
connection, as well as the triggering of message processing.
:param bool force: Forces the creation of a new connection timer,
even if one already exists. When this occurs,
if a timer already exists, it will be stopped.
"""
if self._CHECK_CONNECTION_TIMER is None or force:
self.log_debug("Creating connection timer...")
if self._CHECK_CONNECTION_TIMER:
self.log_debug(
"Connection timer already exists, so it will be stopped."
)
try:
self._CHECK_CONNECTION_TIMER.stop()
except Exception:
# No reason to be alarmed here. Just let it go and it'll
# garbage collected when appropriate.
pass
from sgtk.platform.qt import QtCore
timer = QtCore.QTimer(
parent=QtCore.QCoreApplication.instance(),
)
timer.timeout.connect(self._check_connection)
# The class variable is in seconds, so multiply to get milliseconds.
timer.start(
self.SHOTGUN_ADOBE_HEARTBEAT_INTERVAL * 1000.0,
)
self._CHECK_CONNECTION_TIMER = timer
self.log_debug("Connection timer created and started.")
评论列表
文章目录