Skip to content

Fix #776: fix sync socket close helper method #777

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

Merged
merged 3 commits into from
Aug 19, 2022
Merged
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
9 changes: 6 additions & 3 deletions neo4j/_async_compat/network/_bolt_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
if t.TYPE_CHECKING:
import typing_extensions as te

from ..._async.io import AsyncBolt
from ..._sync.io import Bolt

from ... import addressing
from ..._deadline import Deadline
from ..._exceptions import (
Expand Down Expand Up @@ -75,7 +78,7 @@ def _sanitize_deadline(deadline):


class AsyncBoltSocket:
Bolt: te.Final[t.Type] = None # type: ignore[assignment]
Bolt: te.Final[t.Type[AsyncBolt]] = None # type: ignore[assignment]

def __init__(self, reader, protocol, writer):
self._reader = reader # type: asyncio.StreamReader
Expand Down Expand Up @@ -405,7 +408,7 @@ async def connect(cls, address, *, timeout, custom_resolver, ssl_context,


class BoltSocket:
Bolt: te.Final[t.Type] = None # type: ignore[assignment]
Bolt: te.Final[t.Type[Bolt]] = None # type: ignore[assignment]

def __init__(self, socket_: socket):
self._socket = socket_
Expand Down Expand Up @@ -605,7 +608,7 @@ def _handshake(cls, s, resolved_address):
def close_socket(cls, socket_):
try:
if isinstance(socket_, BoltSocket):
socket.close()
socket_.close()
else:
socket_.shutdown(SHUT_RDWR)
socket_.close()
Expand Down