def connection(request): protocol = GremlinServerWSProtocol( GraphSONMessageSerializer(), username='******', password='******') executor = concurrent.futures.ThreadPoolExecutor(5) pool = queue.Queue() try: conn = Connection('ws://localhost:45941/gremlin', 'gmodern', protocol, lambda: TornadoTransport(), executor, pool) except OSError: executor.shutdown() pytest.skip('Gremlin Server is not running') else: def fin(): executor.shutdown() conn.close() request.addfinalizer(fin) return conn
#!/usr/bin/python3 # freshReadmeSnippet: example from gremlin_python.driver.client import Client from gremlin_python.driver.request import RequestMessage from gremlin_python.driver.serializer import GraphSONMessageSerializer serializer = GraphSONMessageSerializer() # workaround to avoid exception on any opProcessor other than `standard` or `traversal`: serializer.cypher = serializer.standard client = Client('ws://localhost:8182/gremlin', 'g', message_serializer=serializer) cypherQuery = 'MATCH (n) RETURN n.name' message = RequestMessage('cypher', 'eval', {'gremlin': cypherQuery}) results = client.submit(message).all().result() # freshReadmeSnippet: example print(results) assert results == [{ 'n.name': 'marko' }, { 'n.name': 'vadas' }, { 'n.name': 'lop' }, { 'n.name': 'josh' }, {