async def get(self): ws = WebSocketResponse() await ws.prepare(self.request) with self.resource: while not ws.closed: try: item = await asyncio.wait_for(self.resource.queue.get(), 2) except asyncio.TimeoutError: ws.ping() continue except asyncio.CancelledError: break if item['action'] == 'cleared': data = {'action': 'cleared'} elif item['action'] == 'received': data = { 'action': 'received', 'msg': serialize_message(item['msg']), } else: data = None if data: ws.send_str(json.dumps(data)) return ws
def test_ping_closed(self): req = self.make_request('GET', '/') ws = WebSocketResponse() ws.start(req) self.loop.run_until_complete(ws.close()) with self.assertRaises(RuntimeError): ws.ping()
def test_ping_closed(make_request): req = make_request('GET', '/') ws = WebSocketResponse() yield from ws.prepare(req) yield from ws.close() with pytest.raises(RuntimeError): ws.ping()
def test_ping_closed(make_request): req = make_request('GET', '/') ws = WebSocketResponse() yield from ws.prepare(req) yield from ws.close() with pytest.raises(RuntimeError): ws.ping()
def test_ping_closed(self): req = self.make_request("GET", "/") ws = WebSocketResponse() self.loop.run_until_complete(ws.prepare(req)) self.loop.run_until_complete(ws.close()) with self.assertRaises(RuntimeError): ws.ping()
def test_ping_closing(self): req = self.make_request('GET', '/') ws = WebSocketResponse() ws.start(req) ws.close() with self.assertRaises(RuntimeError): ws.ping()
def test_ping_closed(make_request, mocker): req = make_request('GET', '/') ws = WebSocketResponse() yield from ws.prepare(req) yield from ws.close() mocker.spy(ws_logger, 'warning') ws.ping() assert ws_logger.warning.called
def function835(function271, arg1247): var816 = function271('GET', '/') var1269 = WebSocketResponse() yield from var1269.prepare(var816) var1269._reader.feed_data(WS_CLOSED_MESSAGE, 0) yield from var1269.close() arg1247.spy(ws_logger, 'warning') var1269.ping() assert ws_logger.warning.called
async def test_ping_closed(make_request, mocker): req = make_request('GET', '/') ws = WebSocketResponse() await ws.prepare(req) ws._reader.feed_data(WS_CLOSED_MESSAGE, 0) await ws.close() mocker.spy(ws_logger, 'warning') ws.ping() assert ws_logger.warning.called
def test_ping_closed(make_request, mocker): req = make_request('GET', '/') ws = WebSocketResponse() yield from ws.prepare(req) ws._reader.feed_data(WS_CLOSED_MESSAGE, 0) yield from ws.close() mocker.spy(ws_logger, 'warning') ws.ping() assert ws_logger.warning.called
def test_nonstarted_ping(): ws = WebSocketResponse() with pytest.raises(RuntimeError): ws.ping()
def test_nonstarted_ping(self): ws = WebSocketResponse() with self.assertRaises(RuntimeError): ws.ping()
def test_nonstarted_ping(): ws = WebSocketResponse() with pytest.raises(RuntimeError): ws.ping()
def function2584(): var1663 = WebSocketResponse() with pytest.raises(RuntimeError): var1663.ping()