See https://github.com/python/asyncio/pull/291 for details.
def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
raise NotImplementedError
+ def is_closing(self):
+ return self._closed
+
def close(self):
if self._closed:
return
def _set_extra(self, sock):
self._extra['pipe'] = sock
+ def is_closing(self):
+ return self._closing
+
def close(self):
if self._closing:
return
def abort(self):
self._force_close(None)
+ def is_closing(self):
+ return self._closing
+
def close(self):
if self._closing:
return
"""Get optional transport information."""
return self._ssl_protocol._get_extra_info(name, default)
+ def is_closing(self):
+ return self._closed
+
def close(self):
"""Close the transport.
if exc is not None:
raise exc
if self._transport is not None:
- if self._transport._closing:
+ if self._transport.is_closing():
# Yield to the event loop so connection_lost() may be
# called. Without this, _drain_helper() would return
# immediately, and code that calls
"""Get optional transport information."""
return self._extra.get(name, default)
+ def is_closing(self):
+ """Return True if the transport is closing or closed."""
+ raise NotImplementedError
+
def close(self):
"""Close the transport.
def resume_reading(self):
self._loop.add_reader(self._fileno, self._read_ready)
+ def is_closing(self):
+ return self._closing
+
def close(self):
if not self._closing:
self._close(None)
self._loop.remove_reader(self._fileno)
self._loop.call_soon(self._call_connection_lost, None)
+ def is_closing(self):
+ return self._closing
+
def close(self):
if self._pipe is not None and not self._closing:
# write_eof is all what we needed to close the write pipe
tr.close()
test_utils.run_briefly(self.loop)
self.protocol.connection_lost.assert_called_with(None)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertEqual(tr._conn_lost, 1)
self.protocol.connection_lost.reset_mock()
self.loop, self.sock, self.protocol)
self.assertTrue(tr.can_write_eof())
tr.write_eof()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.loop._run_once()
self.assertTrue(self.sock.close.called)
tr.close()
tr._loop._proactor.send.return_value = f
tr.write(b'data')
tr.write_eof()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertFalse(self.sock.shutdown.called)
tr._loop._proactor.send.assert_called_with(self.sock, b'data')
f.set_result(4)
tr = self.create_transport()
tr.close()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertEqual(1, self.loop.remove_reader_count[7])
self.protocol.connection_lost(None)
self.assertEqual(tr._conn_lost, 1)
self.loop.add_writer(7, mock.sentinel)
tr._force_close(None)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertEqual(tr._buffer, list_to_buffer())
self.assertFalse(self.loop.readers)
self.assertFalse(self.loop.writers)
tr = self._make_one()
tr.close()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertEqual(1, self.loop.remove_reader_count[1])
self.assertEqual(tr._conn_lost, 1)
self.assertTrue(protocol.connection_lost.called)
self.assertEqual(protocol.connection_lost.call_args[0], (None,))
- self.assertFalse(transport._closed)
+ self.assertFalse(transport.is_closing())
self.assertIsNone(transport._loop)
self.assertIsNone(transport._proc)
self.assertIsNone(transport._protocol)
tr = self.read_pipe_transport()
err = object()
tr._close(err)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertFalse(self.loop.readers)
test_utils.run_briefly(self.loop)
self.protocol.connection_lost.assert_called_with(err)
tr._read_ready()
self.assertFalse(self.loop.readers)
self.assertFalse(self.loop.writers)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
test_utils.run_briefly(self.loop)
self.protocol.connection_lost.assert_called_with(None)
self.assertFalse(self.loop.writers)
self.assertFalse(self.loop.readers)
self.assertEqual([], tr._buffer)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
m_logexc.assert_called_with(
test_utils.MockPattern(
'Fatal write error on pipe transport'
self.assertFalse(self.loop.readers)
self.assertFalse(self.loop.writers)
self.assertEqual([], tr._buffer)
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
test_utils.run_briefly(self.loop)
self.protocol.connection_lost.assert_called_with(None)
def test_write_eof(self):
tr = self.write_pipe_transport()
tr.write_eof()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertFalse(self.loop.readers)
test_utils.run_briefly(self.loop)
self.protocol.connection_lost.assert_called_with(None)
tr = self.write_pipe_transport()
tr._buffer = [b'data']
tr.write_eof()
- self.assertTrue(tr._closing)
+ self.assertTrue(tr.is_closing())
self.assertFalse(self.protocol.connection_lost.called)