pyadb: Add timeout when first establishing a TCP connection

According to the docs for create_connection(): "Passing the optional
timeout parameter will set the timeout on the socket instance before
attempting to connect."
https://docs.python.org/3/library/socket.html#socket.create_connection

It seems our settimeout() call wasn't applying for the initial connect.
Probably wouldn't hurt to do so. This may help avoid connection errors
on network android devices on swarming, eg:
http://screen/BELTMsAmYHmsRov

This also changes "_OpenHandle" to gracefully catch these TCP-specific
exceptions. It was already catching USB-specific ones. So prob not a
bad idea to expand TCP coverage as well.

Bug: 538124588
Change-Id: If0fb634b73aa7d646089aaad3a59f7a2c6dd234b
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/8161499
Reviewed-by: Haiyang Pan <hypan@google.com>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
2 files changed