Skip to content

Commit 15d8659

Browse files
committed
plishing
1 parent 9c1bc05 commit 15d8659

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

splitio/push/sse.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,4 @@ async def shutdown(self):
274274
self._shutdown_requested = True
275275
sock = self._session.connector._loop._ssock
276276
sock.shutdown(socket.SHUT_RDWR)
277-
await self._conn.close()
278-
for task in asyncio.Task.all_tasks():
279-
if not task.done():
280-
if task._coro.cr_code.co_name == 'connect_split_sse_client':
281-
task.cancel()
277+
await self._conn.close()

tests/push/test_sse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def runner():
128128
class SSEClientAsyncTests(object):
129129
"""SSEClient test cases."""
130130

131+
# @pytest.mark.asyncio
131132
async def test_sse_client_disconnects(self):
132133
"""Test correct initialization. Client ends the connection."""
133134
server = SSEMockServer()
@@ -139,16 +140,18 @@ async def callback(event):
139140
events.append(event)
140141

141142
client = SSEClientAsync(callback)
143+
142144
async def connect_split_sse_client():
143145
await client.start('http://127.0.0.1:' + str(server.port()))
144146

145-
asyncio.gather(connect_split_sse_client())
147+
self._client_task = asyncio.gather(connect_split_sse_client())
146148
server.publish({'id': '1'})
147149
server.publish({'id': '2', 'event': 'message', 'data': 'abc'})
148150
server.publish({'id': '3', 'event': 'message', 'data': 'def'})
149151
server.publish({'id': '4', 'event': 'message', 'data': 'ghi'})
150152
await asyncio.sleep(1)
151153
await client.shutdown()
154+
self._client_task.cancel()
152155
await asyncio.sleep(1)
153156

154157
assert events == [
@@ -212,7 +215,7 @@ async def runner():
212215
"""SSE client runner thread."""
213216
await client.start('http://127.0.0.1:' + str(server.port()))
214217

215-
client_task = asyncio.get_event_loop().create_task(runner())
218+
client_task = asyncio.gather(runner())
216219

217220
server.publish({'id': '1'})
218221
server.publish({'id': '2', 'event': 'message', 'data': 'abc'})

0 commit comments

Comments
 (0)