@@ -76,54 +76,54 @@ async def connect_and_provide_credentials(
7676 ):
7777 import asyncio
7878
79- # try:
80- # Start connection as an async task in the main event loop
81- # This allows the browser to be opened from the main thread context
82- connect_task = asyncio .create_task (self .connect_and_execute_simple_query ())
83-
84- if self .auth_test_env == "docker" :
85- # Give connection time to start and open the browser
86- await asyncio .sleep (5 )
87-
88- # Run browser automation in a thread WITHOUT blocking the event loop
89- # This allows the connection task to continue making progress
90- loop = asyncio .get_running_loop ()
91- credentials_task = loop .run_in_executor (
92- None ,
93- self ._provide_credentials ,
94- scenario ,
95- login ,
96- password ,
97- )
79+ try :
80+ # Start connection as an async task in the main event loop
81+ # This allows the browser to be opened from the main thread context
82+ connect_task = asyncio .create_task (self .connect_and_execute_simple_query ())
83+
84+ if self .auth_test_env == "docker" :
85+ # Give connection time to start and open the browser
86+ await asyncio .sleep (5 )
87+
88+ # Run browser automation in a thread WITHOUT blocking the event loop
89+ # This allows the connection task to continue making progress
90+ loop = asyncio .get_running_loop ()
91+ credentials_task = loop .run_in_executor (
92+ None ,
93+ self ._provide_credentials ,
94+ scenario ,
95+ login ,
96+ password ,
97+ )
9898
99- # Wait for both tasks to complete concurrently
100- await asyncio .gather (connect_task , credentials_task )
101- else :
102- # Wait for connection to complete
103- await connect_task
99+ # Wait for both tasks to complete concurrently
100+ await asyncio .gather (connect_task , credentials_task )
101+ else :
102+ # Wait for connection to complete
103+ await connect_task
104104
105- # except Exception as e:
106- # self.error_msg = e
107- # logger.error(e)
105+ except Exception as e :
106+ self .error_msg = e
107+ logger .error (e )
108108
109109 def get_error_msg (self ) -> str :
110110 return str (self .error_msg )
111111
112112 async def connect_and_execute_simple_query (self ):
113- # try:
114- logger .info ("Trying to connect to Snowflake" )
115- async with snowflake .connector .aio .SnowflakeConnection (
116- ** self .configuration
117- ) as con :
118- logger .info ("Connected to Snowflake, executing query" )
119- result = await con .cursor ().execute ("select 1;" )
120- logger .debug (await result .fetchall ())
121- logger .info ("Successfully connected to Snowflake" )
122- return True
123- # except Exception as e:
124- # self.error_msg = e
125- # logger.error(e)
126- # return False
113+ try :
114+ logger .info ("Trying to connect to Snowflake" )
115+ async with snowflake .connector .aio .SnowflakeConnection (
116+ ** self .configuration
117+ ) as con :
118+ logger .info ("Connected to Snowflake, executing query" )
119+ result = await con .cursor ().execute ("select 1;" )
120+ logger .debug (await result .fetchall ())
121+ logger .info ("Successfully connected to Snowflake" )
122+ return True
123+ except Exception as e :
124+ self .error_msg = e
125+ logger .error (e )
126+ return False
127127
128128 async def connect_and_execute_set_session_state (self , key : str , value : str ):
129129 try :
@@ -172,7 +172,7 @@ def _provide_credentials(self, scenario: Scenario, login: str, password: str):
172172 ],
173173 timeout = 30 ,
174174 )
175- # logger.debug(f"OUTPUT: {process.stdout}, ERRORS: {process.stderr}")
175+ logger .debug (f"OUTPUT: { process .stdout } , ERRORS: { process .stderr } " )
176176 except Exception as e :
177177 self .error_msg = e
178178 raise RuntimeError (e )
0 commit comments