def METHOD_NAME(self, server):
    try:
        session = socket.socket()
        # use 5 second timeout for initial connection attempts
        session.settimeout(5)
        session.METHOD_NAME((server, 14580))
        # use 30 second timeout for rest of transaction
        session.settimeout(30)
        yield session
    finally:
        session.close()