Skip to content

Commit 0f7d923

Browse files
authored
Merge pull request #305 from rethinkdb/srh/wait_closed35
Only call wait_closed when Python >= 3.7
2 parents 410880d + 4c594dd commit 0f7d923

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rethinkdb/asyncio_net/net_asyncio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import socket
2121
import ssl
2222
import struct
23+
import sys
2324

2425
from rethinkdb import ql2_pb2
2526
from rethinkdb.errors import (
@@ -156,6 +157,8 @@ def _maybe_fetch_batch(self):
156157
self.outstanding_requests += 1
157158
asyncio.ensure_future(self.conn._parent._continue(self))
158159

160+
# Python <3.7's StreamWriter has no wait_closed().
161+
DO_WAIT_CLOSED = sys.version_info >= (3, 7)
159162

160163
class ConnectionInstance(object):
161164
_streamreader = None
@@ -274,7 +277,9 @@ async def close(self, noreply_wait=False, token=None, exception=None):
274277
await self.run_query(noreply, False)
275278

276279
self._streamwriter.close()
277-
await self._streamwriter.wait_closed()
280+
# Python <3.7 has no wait_closed().
281+
if DO_WAIT_CLOSED:
282+
await self._streamwriter.wait_closed()
278283
# We must not wait for the _reader_task if we got an exception, because that
279284
# means that we were called from it. Waiting would lead to a deadlock.
280285
if self._reader_task and exception is None:

0 commit comments

Comments
 (0)