Skip to content

Instantly share code, notes, and snippets.

View davebshow's full-sized avatar

David Michael Brown davebshow

  • Vancouver Island
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import uuid
from tornado.concurrent import Future
from tornado.websocket import websocket_connect
class GremlinResponseStream:
def __init__(self, conn):
self._conn = conn
@asyncio.coroutine
@davebshow
davebshow / traversal_dependency.py
Last active November 6, 2015 17:15
My basic idea for creating a schema dependency graph based on the traversal fragments generated by SylvaDB query builder.
def df_edge_traversal(g):
"""
Based on networkx dfs_edges
"""
visited = set()
start = g.nodes()[0]
stack = [(start, iter(g[start]))]
while stack:
parent, children = stack[-1]
try:
match path=(t:tweet {tid: '665496205854687232'})-[:REPLIES_TO|RETWEETS|TWEETS*1..4]-(:tweet) return filter(x in nodes(path) where exists(x.tid))
@davebshow
davebshow / a_aioclient.py
Last active July 24, 2017 01:28
This gist details some simple profiling that I did to compare compare a Tornado based client implementation vs. a Aiohttp based implementation of gremlinclient. To do so, I simply dropped the Aiohttp websocket client in the place of the Tornado client in gremlinclient like shown in the following file. Next I did a simple IPython %timeit, followe…
import asyncio
import collections
import json
import uuid
import aiohttp
Message = collections.namedtuple(
"Message",
import asyncio
import datetime
from pytz import utc
from tornado.platform.asyncio import AsyncIOMainLoop
from mogwai import properties
from mogwai.connection import setup, close_global_pool
from mogwai.models import Vertex, Edge, V
"""
Simple client for the JSONRPC Server
"""
import asyncio
from pulsar.apps import rpc
proxy = rpc.JsonProxy("http://localhost:8060")
"""
This example demonstrates how to use Pulsar actors to create
nodes with Goblin. This is the basic concept on which other Pulsar/Goblin
apps would be based, but it may be better to use Pulsar's higher
level Application class interface...
Based on:
https://github.com/quantmind/pulsar/blob/master/examples/snippets/greeter.py
"""
import asyncio
import pulsar
import asyncio
import pulsar
from pulsar.apps import ws, wsgi
class Echo(ws.WS):
def on_bytes(self, websocket, msg):
websocket._loop.call_soon(
pulsar.ensure_future, self._call(websocket, msg))
import asyncio
import datetime
from pytz import utc
from tornado.platform.asyncio import AsyncIOMainLoop
from goblin import properties
from goblin.connection import setup, tear_down
from goblin.models import Vertex, Edge, V