MCPcopy Create free account
hub / github.com/ActiveState/code / create_connection

Function create_connection

recipes/Python/578889_socketsendfile/recipe-578889.py:274–282  ·  view source on GitHub ↗
(address, timeout=None)

Source from the content-addressed store, hash-verified

272
273 @contextlib.contextmanager
274 def create_connection(address, timeout=None):
275 sock = socket.socket()
276 sock.connect(address)
277 if timeout is not None:
278 sock.settimeout(timeout)
279 try:
280 yield sock
281 finally:
282 sock.close()
283
284 class ThreadableTest:
285 """Threadable Test class

Callers 10

_testRegularFileMethod · 0.70
_testNonRegularFileMethod · 0.70
_testEmptyFileSendMethod · 0.70
_testOffsetMethod · 0.70
_testCountMethod · 0.70
_testCountSmallMethod · 0.70
_testCountWithOffsetMethod · 0.70
_testNonBlockingMethod · 0.70
_testWithTimeoutMethod · 0.70

Calls 4

socketMethod · 0.80
connectMethod · 0.45
settimeoutMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected