File tree Expand file tree Collapse file tree
py/selenium/webdriver/firefox Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515# specific language governing permissions and limitations
1616# under the License.
1717import base64
18+ import logging
1819import os
1920import warnings
2021import zipfile
3233from .service import DEFAULT_EXECUTABLE_PATH
3334from .service import Service
3435
36+ logger = logging .getLogger (__name__ )
37+
3538# Default for log_path variable. To be deleted when deprecations for arguments are removed.
3639DEFAULT_LOG_PATH = None
3740DEFAULT_SERVICE_LOG_PATH = "geckodriver.log"
@@ -212,8 +215,24 @@ def quit(self) -> None:
212215 rmtree (self .profile .path )
213216 if self .profile .tempfolder :
214217 rmtree (self .profile .tempfolder )
215- except Exception as e :
216- print (str (e ))
218+ except Exception :
219+ logger .exception ("Unable to remove profile specific paths." )
220+
221+ self ._close_binary_file_handle ()
222+
223+ def _close_binary_file_handle (self ) -> None :
224+ """Attempts to close the underlying file handles for `FirefoxBinary`
225+ instances if they are used and open.
226+
227+ To keep inline with other cleanup raising here is swallowed and
228+ will not cause a runtime error.
229+ """
230+ try :
231+ if isinstance (self .binary , FirefoxBinary ):
232+ if hasattr (self .binary ._log_file , "close" ):
233+ self .binary ._log_file .close ()
234+ except Exception :
235+ logger .exception ("Unable to close open file handle for firefox binary log file." )
217236
218237 @property
219238 def firefox_profile (self ):
You can’t perform that action at this time.
0 commit comments