Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SG-35999 Create a hook for socketIO prepare_http_session #80

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions python/tk_framework_adobe/rpc/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# not expressly granted therein are reserved by Shotgun Software Inc.
import threading
import sys
import os.path
import os
import time
import logging
import contextlib
Expand All @@ -35,8 +35,8 @@
sys.path.insert(0, pkgs_zip_path)


import socketIO_client_nexus
import socketIO_client_nexus.exceptions
from socketIO_client_nexus import SocketIO
from .proxy import ProxyScope, ProxyWrapper, ClassInstanceProxyWrapper

import sgtk
Expand All @@ -46,6 +46,22 @@
except ImportError:
from tank_vendor import six as sgutils

if os.environ.get("SGTK_ENFORCE_PROXY_LOCALHOST", "0").strip().lower() not in [
"1",
"true",
"y",
"yes",
]:
# Hook socketIO_client_nexus.prepare_http_session to disable Proxy
prepare_http_session_bak = socketIO_client_nexus.prepare_http_session

def my_prepare_http_session(kw):
http_session = prepare_http_session_bak(kw)
http_session.trust_env = False
return http_session

socketIO_client_nexus.prepare_http_session = my_prepare_http_session


class Communicator(object):
"""
Expand Down Expand Up @@ -99,7 +115,7 @@ def __init__(
self._event_processor = event_processor
self._response_logging_silenced = False

self._io = SocketIO(host, port)
self._io = socketIO_client_nexus.SocketIO(host, port)
self._io.on("return", self._handle_response)

self._global_scope = None
Expand Down