Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions neo4j/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class Bolt(abc.ABC):
def __init__(self, unresolved_address, sock, max_connection_lifetime, *, auth=None, user_agent=None, routing_context=None):
self.unresolved_address = unresolved_address
self.socket = sock
self.local_port = self.socket.getsockname()[1]
self.server_info = ServerInfo(Address(sock.getpeername()), self.PROTOCOL_VERSION)
# so far `connection.recv_timeout_seconds` is the only available
# configuration hint that exists. Therefore, all hints can be stored at
Expand Down Expand Up @@ -373,11 +374,6 @@ def encrypted(self):
def der_encoded_server_certificate(self):
pass

@property
@abc.abstractmethod
def local_port(self):
pass

@abc.abstractmethod
def hello(self):
""" Appends a HELLO message to the outgoing queue, sends it and consumes
Expand Down
7 changes: 0 additions & 7 deletions neo4j/io/_bolt3.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ def encrypted(self):
def der_encoded_server_certificate(self):
return self.socket.getpeercert(binary_form=True)

@property
def local_port(self):
try:
return self.socket.getsockname()[1]
except OSError:
return 0

def get_base_headers(self):
return {
"user_agent": self.user_agent,
Expand Down
7 changes: 0 additions & 7 deletions neo4j/io/_bolt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ def encrypted(self):
def der_encoded_server_certificate(self):
return self.socket.getpeercert(binary_form=True)

@property
def local_port(self):
try:
return self.socket.getsockname()[1]
except OSError:
return 0

def get_base_headers(self):
return {
"user_agent": self.user_agent,
Expand Down
3 changes: 2 additions & 1 deletion neo4j/io/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MessageInbox:

def __init__(self, s, on_error):
self.on_error = on_error
self._local_port = s.getsockname()[1]
self._messages = self._yield_messages(s)

def _yield_messages(self, sock):
Expand All @@ -55,7 +56,7 @@ def _yield_messages(self, sock):
buffer.receive(sock, 2)
chunk_size = buffer.pop_u16()
if chunk_size == 0:
log.debug("[#%04X] S: <NOOP>", sock.getsockname()[1])
log.debug("[#%04X] S: <NOOP>", self._local_port)

buffer.receive(sock, chunk_size + 2)
chunk_size = buffer.pop_u16()
Expand Down
1 change: 1 addition & 0 deletions tests/unit/work/_fake_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
class FakeConnection(mock.NonCallableMagicMock):
callbacks = []
server_info = ServerInfo("127.0.0.1", (4, 3))
local_port = 1234

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down