Skip to content

Feed memoryview to writelines() #715

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2021
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
4 changes: 2 additions & 2 deletions asyncpg/protocol/coreproto.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ cdef class CoreProtocol:
else:
# otherwise, append SYNC and send the buffers
packet.write_bytes(SYNC_MESSAGE)
buffers.append(packet)
buffers.append(memoryview(packet))
self._writelines(buffers)
return False

Expand All @@ -976,7 +976,7 @@ cdef class CoreProtocol:
)

# collected one buffer
buffers.append(packet)
buffers.append(memoryview(packet))

# write to the wire, and signal the caller for more to send
self._writelines(buffers)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,30 @@ async def worker():
await asyncio.gather(*tasks)
await pool.close()

async def test_executemany_uvloop_ssl_issue_700(self):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.load_verify_locations(SSL_CA_CERT_FILE)

con = await self.connect(
host='localhost',
user='ssl_user',
ssl=ssl_context)

try:
await con.execute('CREATE TABLE test_many (v int)')
await con.executemany(
'INSERT INTO test_many VALUES ($1)',
[(x + 1,) for x in range(100)]
)
self.assertEqual(
await con.fetchval('SELECT sum(v) FROM test_many'), 5050
)
finally:
try:
await con.execute('DROP TABLE test_many')
finally:
await con.close()


class TestConnectionGC(tb.ClusterTestCase):

Expand Down