Skip to content

Instantly share code, notes, and snippets.

@davebshow
Last active September 12, 2016 18:00
Show Gist options
  • Save davebshow/3a0b0679620ddbd9c23eaaa2ddca1411 to your computer and use it in GitHub Desktop.
Save davebshow/3a0b0679620ddbd9c23eaaa2ddca1411 to your computer and use it in GitHub Desktop.
import asyncio
import uvloop
from aiohttp import ClientSession
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
msg = b'\x10application/json{"processor": "", "op": "eval", "args": {"aliases": {}, "gremlin": "x + x", "bindings": {"x": 1}}, "requestId": "2f52dced-0c4d-4ccd-a8a6-62a59bbb52af"}'
async def test():
session = ClientSession()
ws = await session.ws_connect('ws://localhost:8182/gremlin')
for x in range(1200):
ws.send_bytes(msg)
await receive(ws)
await session.close()
async def receive(ws):
for x in range(1200):
resp = await ws.receive()
# print(resp)
await ws.close()
def go():
loop = asyncio.get_event_loop()
loop.run_until_complete(test())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment