Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guy Rozendorn
AIO Gremlin
Commits
075a9f13
Commit
075a9f13
authored
Oct 30, 2017
by
davebshow
Browse files
starting to decouple code from aiohttp
parent
4317096c
Changes
4
Hide whitespace changes
Inline
Side-by-side
aiogremlin/driver/aiohttp/transport.py
View file @
075a9f13
...
...
@@ -22,7 +22,22 @@ class AiohttpTransport(transport.AbstractBaseTransport):
self
.
_ws
.
send_bytes
(
message
)
async
def
read
(
self
):
return
await
self
.
_ws
.
receive
()
data
=
await
self
.
_ws
.
receive
()
if
data
.
tp
==
aiohttp
.
WSMsgType
.
close
:
await
self
.
_transport
.
close
()
raise
RuntimeError
(
"Connection closed by server"
)
elif
data
.
tp
==
aiohttp
.
WSMsgType
.
error
:
# This won't raise properly, fix
raise
data
.
data
elif
data
.
tp
==
aiohttp
.
WSMsgType
.
closed
:
# Hmm
raise
RuntimeError
(
"Connection closed by server"
)
elif
data
.
tp
==
aiohttp
.
WSMsgType
.
text
:
# Should return bytes
data
=
data
.
data
.
strip
().
encode
(
'utf-8'
)
else
:
data
=
data
.
data
return
data
async
def
close
(
self
):
if
self
.
_connected
:
...
...
aiogremlin/driver/connection.py
View file @
075a9f13
import
abc
import
asyncio
import
base64
import
collections
import
logging
import
uuid
import
aiohttp
try
:
import
ujson
as
json
except
ImportError
:
...
...
@@ -135,7 +130,9 @@ class Connection:
request_id
,
message
)
if
self
.
_transport
.
closed
:
await
self
.
_transport
.
connect
(
self
.
url
)
self
.
_transport
.
write
(
message
)
func
=
self
.
_transport
.
write
(
message
)
if
asyncio
.
iscoroutine
(
func
):
await
func
result_set
=
resultset
.
ResultSet
(
request_id
,
self
.
_response_timeout
,
self
.
_loop
)
self
.
_result_sets
[
request_id
]
=
result_set
...
...
requirements.txt
deleted
100644 → 0
View file @
4317096c
aiohttp
==1.3.3
PyYAML
==3.12
tests/test_gremlin_python/driver/test_driver_remote_connection.py
View file @
075a9f13
...
...
@@ -21,8 +21,6 @@ import pytest
from
gremlin_python
import
statics
from
gremlin_python.statics
import
long
from
aiogremlin.remote.driver_remote_connection
import
(
DriverRemoteConnection
)
from
gremlin_python.process.traversal
import
Traverser
from
gremlin_python.process.traversal
import
TraversalStrategy
from
gremlin_python.process.graph_traversal
import
__
...
...
@@ -35,6 +33,12 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
class
TestDriverRemoteConnection
(
object
):
@
pytest
.
mark
.
asyncio
async
def
test_label
(
self
,
remote_connection
):
statics
.
load_statics
(
globals
())
g
=
Graph
().
traversal
().
withRemote
(
remote_connection
)
result
=
await
g
.
V
().
limit
(
1
).
toList
()
@
pytest
.
mark
.
asyncio
async
def
test_traversals
(
self
,
remote_connection
):
statics
.
load_statics
(
globals
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment