Skip to content

Commit 5aedd5b

Browse files
committed
connection->bolt
1 parent 01970c4 commit 5aedd5b

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

neo4j/v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21-
from .connection import ProtocolError
21+
from .bolt import ProtocolError
2222
from .constants import *
2323
from .session import *
2424
from .types import *

neo4j/v1/connection.py renamed to neo4j/v1/bolt.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
from socket import create_connection, SHUT_RDWR, error as SocketError
3232
from struct import pack as struct_pack, unpack as struct_unpack, unpack_from as struct_unpack_from
3333

34-
import errno
35-
3634
from .constants import DEFAULT_PORT, DEFAULT_USER_AGENT, KNOWN_HOSTS, MAGIC_PREAMBLE, \
3735
TRUST_DEFAULT, TRUST_ON_FIRST_USE
3836
from .compat import hex2
@@ -239,6 +237,13 @@ def on_failure(metadata):
239237
def __del__(self):
240238
self.close()
241239

240+
@property
241+
def healthy(self):
242+
""" Return ``True`` if this connection is healthy, ``False`` if
243+
unhealthy and ``None`` if closed.
244+
"""
245+
return None if self.closed else not self.defunct
246+
242247
def append(self, signature, fields=(), response=None):
243248
""" Add a message to the outgoing queue.
244249
@@ -333,6 +338,12 @@ def fetch(self):
333338
handler(*fields)
334339
raw.close()
335340

341+
def fetch_all(self):
342+
while self.responses:
343+
response = self.responses[0]
344+
while not response.complete:
345+
self.fetch()
346+
336347
def close(self):
337348
""" Close the connection.
338349
"""

neo4j/v1/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class which can be used to obtain `Driver` instances that are used for
3131
from collections import deque, namedtuple
3232

3333
from .compat import integer, string, urlparse
34-
from .connection import connect, Response, RUN, PULL_ALL
34+
from .bolt import connect, Response, RUN, PULL_ALL
3535
from .constants import ENCRYPTED_DEFAULT, TRUST_DEFAULT, TRUST_SIGNED_CERTIFICATES
3636
from .exceptions import CypherError, ProtocolError, ResultError
3737
from .ssl_compat import SSL_AVAILABLE, SSLContext, PROTOCOL_SSLv23, OP_NO_SSLv2, CERT_REQUIRED

test/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def test_automatic_reset_after_failure(self):
346346
assert False, "A Cypher error should have occurred"
347347

348348
def test_defunct(self):
349-
from neo4j.v1.connection import ChunkChannel, ProtocolError
349+
from neo4j.v1.bolt import ChunkChannel, ProtocolError
350350
with GraphDatabase.driver("bolt://localhost", auth=auth_token).session() as session:
351351
assert not session.connection.defunct
352352
with patch.object(ChunkChannel, "chunk_reader", side_effect=ProtocolError()):

0 commit comments

Comments
 (0)