wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.86k stars 240 forks source link

oserror: [errno 24] too many open files #693

Closed L4871 closed 1 year ago

L4871 commented 1 year ago

After running selenium-wire for a while i encountered error too many files open. I increased the amount of files that system can open (ulimit -n in linux). How ever this didn't fix the problem, now when i leave selenium-wire running after a while i get the following error:

Exception in thread ServerThread (('127.0.0.1', 44477)): Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/master.py", line 36, in run self.server.serve_forever() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/net/tcp.py", line 650, in serveforever r, w, e_ = select.select([self.socket], [], [], poll_interval) ValueError: filedescriptor out of range in select()

Or 127.0.0.1:58906: Traceback (most recent call last): File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py", line 113, in handle root_layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py", line 9, in call layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py", line 285, in call layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in call layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in call if not self._process_flow(flow): File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 285, in _process_flow return self.handle_regular_connect(f) File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 224, in handle_regular_connect layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py", line 100, in call layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 206, in call if not self._process_flow(flow): File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py", line 488, in _process_flow layer() File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/websocket.py", line 194, in call r = tcp.ssl_read_select(conns, 0.1) File "/path/to/project/lib/python3.8/site-packages/seleniumwire/thirdparty/mitmproxy/net/tcp.py", line 226, in ssl_read_select ] or select.select(rlist, (), (), timeout)[0] ValueError: filedescriptor out of range in select()

Any suggestions would be appreciated.

L4871 commented 1 year ago

Fixed the issue by using driver.quit() instead of driver.close().