File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -150,8 +150,14 @@ def __init__(self, session=None):
150150 self .session = session
151151
152152 def __del__ (self ):
153- if hasattr (self , "session" ) and self .session is not None :
154- self .session .close ()
153+ try :
154+ if hasattr (self , "session" ) and self .session is not None :
155+ self .session .close ()
156+ except TypeError :
157+ # NOTE: For certain Python binary built, the queue.Empty exception
158+ # might not be considered a normal Python exception causing
159+ # TypeError.
160+ pass
155161
156162 def __call__ (
157163 self ,
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ def test_session_closed_on_del(self):
5757 request .__del__ ()
5858 http .close .assert_called_with ()
5959
60+ http = mock .create_autospec (requests .Session , instance = True )
61+ http .close .side_effect = TypeError ("test injected TypeError" )
62+ request = google .auth .transport .requests .Request (http )
63+ request .__del__ ()
64+ http .close .assert_called_with ()
65+
6066
6167class TestTimeoutGuard (object ):
6268 def make_guard (self , * args , ** kwargs ):
You can’t perform that action at this time.
0 commit comments