-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Closed
Copy link
Labels
UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModeUndetected Chromedriver Mode / CDP ModebugUh oh... Something needs to be fixedUh oh... Something needs to be fixed
Description
CDP Mode isn't freeing open socket connections after the browser has closed
If activating CDP Mode within a loop of SB()
initializations like this:
for i in range(3):
with SB(uc=True) as sb:
sb.activate_cdp_mode("https://example.com")
...then socket connections aren't being closed properly at the end of the with
block, which leads to a growing number of open socket connections, like this:
pconn(fd=15, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56545), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=16, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56546), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=12, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56609), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=15, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56545), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=16, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56546), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=17, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56610), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=12, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56609), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=15, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56545), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=16, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56546), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=17, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56610), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=21, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56682), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
pconn(fd=22, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=56683), raddr=addr(ip='127.0.0.1', port=9222), status='CLOSE_WAIT')
The socket connections only get freed up after the full program has completed.
Metadata
Metadata
Assignees
Labels
UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModeUndetected Chromedriver Mode / CDP ModebugUh oh... Something needs to be fixedUh oh... Something needs to be fixed