mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #1251 from pypeclub/bugfix/ftrack_api_connection
Ftrack api connection fix
This commit is contained in:
commit
3c268d6693
2 changed files with 18 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import time
|
||||
import types
|
||||
import logging
|
||||
import traceback
|
||||
|
|
@ -10,7 +11,6 @@ from openpype.lib import (
|
|||
modules_from_path
|
||||
)
|
||||
|
||||
|
||||
log = PypeLogger.get_logger(__name__)
|
||||
|
||||
"""
|
||||
|
|
@ -120,6 +120,18 @@ class FtrackServer:
|
|||
if not session:
|
||||
session = ftrack_api.Session(auto_connect_event_hub=True)
|
||||
|
||||
# Wait until session has connected event hub
|
||||
if session._auto_connect_event_hub_thread:
|
||||
# Use timeout from session (since ftrack-api 2.1.0)
|
||||
timeout = getattr(session, "request_timeout", 60)
|
||||
started = time.time()
|
||||
while not session.event_hub.connected:
|
||||
if (time.time() - started) > timeout:
|
||||
raise RuntimeError((
|
||||
"Connection to Ftrack was not created in {} seconds"
|
||||
).format(timeout))
|
||||
time.sleep(0.1)
|
||||
|
||||
self.session = session
|
||||
if load_files:
|
||||
if not self.handler_paths:
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import sys
|
|||
import logging
|
||||
import getpass
|
||||
import atexit
|
||||
import tempfile
|
||||
import threading
|
||||
import datetime
|
||||
import time
|
||||
import queue
|
||||
import appdirs
|
||||
import pymongo
|
||||
|
||||
import requests
|
||||
|
|
@ -165,7 +165,6 @@ class ProcessEventHub(SocketBaseEventHub):
|
|||
|
||||
def wait(self, duration=None):
|
||||
"""Overriden wait
|
||||
|
||||
Event are loaded from Mongo DB when queue is empty. Handled event is
|
||||
set as processed in Mongo DB.
|
||||
"""
|
||||
|
|
@ -252,7 +251,7 @@ class CustomEventHubSession(ftrack_api.session.Session):
|
|||
self, server_url=None, api_key=None, api_user=None, auto_populate=True,
|
||||
plugin_paths=None, cache=None, cache_key_maker=None,
|
||||
auto_connect_event_hub=False, schema_cache_path=None,
|
||||
plugin_arguments=None, **kwargs
|
||||
plugin_arguments=None, timeout=60, **kwargs
|
||||
):
|
||||
self.kwargs = kwargs
|
||||
|
||||
|
|
@ -331,6 +330,7 @@ class CustomEventHubSession(ftrack_api.session.Session):
|
|||
self._request.auth = ftrack_api.session.SessionAuthentication(
|
||||
self._api_key, self._api_user
|
||||
)
|
||||
self.request_timeout = timeout
|
||||
|
||||
self.auto_populate = auto_populate
|
||||
|
||||
|
|
@ -368,8 +368,9 @@ class CustomEventHubSession(ftrack_api.session.Session):
|
|||
# rebuilding types)?
|
||||
if schema_cache_path is not False:
|
||||
if schema_cache_path is None:
|
||||
schema_cache_path = appdirs.user_cache_dir()
|
||||
schema_cache_path = os.environ.get(
|
||||
'FTRACK_API_SCHEMA_CACHE_PATH', tempfile.gettempdir()
|
||||
'FTRACK_API_SCHEMA_CACHE_PATH', schema_cache_path
|
||||
)
|
||||
|
||||
schema_cache_path = os.path.join(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue