Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goblin not working with aiohttp (server) #109

Open
brean opened this issue Oct 16, 2018 · 2 comments
Open

goblin not working with aiohttp (server) #109

brean opened this issue Oct 16, 2018 · 2 comments

Comments

@brean
Copy link

brean commented Oct 16, 2018

Hi,

(UPDATE!) I got it running monkey-patching this pull request into my code. When is this planned to be released?


I am looking for an example of aiohttp and goblin happily working together. I tried to create my own but I am not able to get goblin and aiohttp to work at the same time.

Can you point me to the right versions of aiohttp, goblin and aiogremlin that work together?

You can take a look at a simple example script I wrote here:
https://gist.github.com/brean/cb2630fc3bbe0ce8654bc995829908f3#file-goblin_aiohttp_server-py

I have these versions installed (I am using the current gremlin 3.3.3, but I can downgrade if that solves the issue for now):

aiogremlin==3.3.1
aiohttp==3.4.4
goblin==2.1.0
gremlinpython==3.3.3
PyYAML==3.12
yarl==1.2.6

The error message I get is:

/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/driver/aiohttp/transport.py:22: RuntimeWarning: coroutine 'ClientWebSocketResponse.send_bytes' was never awaited
  self._ws.send_bytes(message)

and because that did not finish correctly the code runs into a timeout:

Error handling request
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/driver/resultset.py", line 86, in one
    loop=self._loop)
  File "/usr/lib64/python3.6/asyncio/tasks.py", line 362, in wait_for
    raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "start.py", line 33, in websocket_handler
    await session.flush()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 242, in flush
    await self.save(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 292, in save
    result = await self.save_vertex(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 311, in save_vertex
    self._update_vertex)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 412, in _save_element
    result = await create_func(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 419, in _add_vertex
    return await self._add_properties(traversal, props, vertex)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 473, in _add_properties
    return await self._simple_traversal(traversal, elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 388, in _simple_traversal
    elem = await traversal.next()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/process/graph_traversal.py", line 61, in next
    return await self.__anext__()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/process/graph_traversal.py", line 17, in __anext__
    self.last_traverser = await self.traversers.__anext__()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/driver/resultset.py", line 66, in __anext__
    msg = await self.one()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/driver/resultset.py", line 10, in wrapper
    msg = await fn(self)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/driver/resultset.py", line 89, in one
    raise exception.ResponseTimeoutError('Response timed out')
aiogremlin.exception.ResponseTimeoutError: Response timed out
Unhandled exception
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 410, in start
    await resp.prepare(request)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_response.py", line 300, in prepare
    return await self._start(request)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_response.py", line 608, in _start
    return await super()._start(request)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_response.py", line 367, in _start
    await writer.write_headers(status_line, headers)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/http_writer.py", line 110, in write_headers
    self._write(buf)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

So the error occurs in aiogremlin/driver/aiohttp/transport.py:22 which is not an async call, but I am not sure if this deserves a bug report in aiogremlin or here.

@brean brean changed the title goblin not working with aiohttp goblin not working with aiohttp (server) Oct 16, 2018
@brean
Copy link
Author

brean commented Oct 16, 2018

downgrading does not work. I tried downgrading to

aiogremlin==3.2.6rc1
aiohttp==2.2.5
yarl==0.18.0

but this only ends in another error:

/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/http_writer.py:317: UserWarning: strict parameter is ignored
  path = yarl.quote(path, safe='@:', protected='/', strict=False)
Error handling request
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "start.py", line 33, in websocket_handler
    await session.flush()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 242, in flush
    await self.save(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 292, in save
    result = await self.save_vertex(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 311, in save_vertex
    self._update_vertex)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 412, in _save_element
    result = await create_func(elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 419, in _add_vertex
    return await self._add_properties(traversal, props, vertex)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 473, in _add_properties
    return await self._simple_traversal(traversal, elem)
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/goblin/session.py", line 388, in _simple_traversal
    elem = await traversal.next()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/process/graph_traversal.py", line 56, in next
    return await self.__anext__()
  File "/home/user/.local/share/virtualenvs/aiohttp-server-janusgraph-xqO7jeAA/lib/python3.6/site-packages/aiogremlin/process/graph_traversal.py", line 18, in __anext__
    object = self.last_traverser.object
AttributeError: 'str' object has no attribute 'object'

@brean
Copy link
Author

brean commented Oct 16, 2018

Looks like this pull request has not made it into a released version, yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant