diff --git a/asyncpg/protocol/coreproto.pyx b/asyncpg/protocol/coreproto.pyx index 12ebf6c6..e7d7c2bc 100644 --- a/asyncpg/protocol/coreproto.pyx +++ b/asyncpg/protocol/coreproto.pyx @@ -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 @@ -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) diff --git a/tests/test_connect.py b/tests/test_connect.py index af927426..5adb977d 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -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):