mirror of https://github.com/python/cpython
Merge 3.4
This commit is contained in:
commit
1334f83de2
|
@ -87,6 +87,9 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||||
def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
|
def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closed
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._closed:
|
if self._closed:
|
||||||
return
|
return
|
||||||
|
|
|
@ -65,6 +65,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
|
||||||
def _set_extra(self, sock):
|
def _set_extra(self, sock):
|
||||||
self._extra['pipe'] = sock
|
self._extra['pipe'] = sock
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closing
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._closing:
|
if self._closing:
|
||||||
return
|
return
|
||||||
|
|
|
@ -556,6 +556,9 @@ class _SelectorTransport(transports._FlowControlMixin,
|
||||||
def abort(self):
|
def abort(self):
|
||||||
self._force_close(None)
|
self._force_close(None)
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closing
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._closing:
|
if self._closing:
|
||||||
return
|
return
|
||||||
|
|
|
@ -304,6 +304,9 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
|
||||||
"""Get optional transport information."""
|
"""Get optional transport information."""
|
||||||
return self._ssl_protocol._get_extra_info(name, default)
|
return self._ssl_protocol._get_extra_info(name, default)
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closed
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the transport.
|
"""Close the transport.
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,7 @@ class StreamWriter:
|
||||||
if exc is not None:
|
if exc is not None:
|
||||||
raise exc
|
raise exc
|
||||||
if self._transport is not None:
|
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
|
# Yield to the event loop so connection_lost() may be
|
||||||
# called. Without this, _drain_helper() would return
|
# called. Without this, _drain_helper() would return
|
||||||
# immediately, and code that calls
|
# immediately, and code that calls
|
||||||
|
|
|
@ -19,6 +19,10 @@ class BaseTransport:
|
||||||
"""Get optional transport information."""
|
"""Get optional transport information."""
|
||||||
return self._extra.get(name, default)
|
return self._extra.get(name, default)
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
"""Return True if the transport is closing or closed."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the transport.
|
"""Close the transport.
|
||||||
|
|
||||||
|
|
|
@ -364,6 +364,9 @@ class _UnixReadPipeTransport(transports.ReadTransport):
|
||||||
def resume_reading(self):
|
def resume_reading(self):
|
||||||
self._loop.add_reader(self._fileno, self._read_ready)
|
self._loop.add_reader(self._fileno, self._read_ready)
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closing
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if not self._closing:
|
if not self._closing:
|
||||||
self._close(None)
|
self._close(None)
|
||||||
|
@ -548,6 +551,9 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
|
||||||
self._loop.remove_reader(self._fileno)
|
self._loop.remove_reader(self._fileno)
|
||||||
self._loop.call_soon(self._call_connection_lost, None)
|
self._loop.call_soon(self._call_connection_lost, None)
|
||||||
|
|
||||||
|
def is_closing(self):
|
||||||
|
return self._closing
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self._pipe is not None and not self._closing:
|
if self._pipe is not None and not self._closing:
|
||||||
# write_eof is all what we needed to close the write pipe
|
# write_eof is all what we needed to close the write pipe
|
||||||
|
|
|
@ -204,7 +204,7 @@ class ProactorSocketTransportTests(test_utils.TestCase):
|
||||||
tr.close()
|
tr.close()
|
||||||
test_utils.run_briefly(self.loop)
|
test_utils.run_briefly(self.loop)
|
||||||
self.protocol.connection_lost.assert_called_with(None)
|
self.protocol.connection_lost.assert_called_with(None)
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertEqual(tr._conn_lost, 1)
|
self.assertEqual(tr._conn_lost, 1)
|
||||||
|
|
||||||
self.protocol.connection_lost.reset_mock()
|
self.protocol.connection_lost.reset_mock()
|
||||||
|
@ -298,7 +298,7 @@ class ProactorSocketTransportTests(test_utils.TestCase):
|
||||||
self.loop, self.sock, self.protocol)
|
self.loop, self.sock, self.protocol)
|
||||||
self.assertTrue(tr.can_write_eof())
|
self.assertTrue(tr.can_write_eof())
|
||||||
tr.write_eof()
|
tr.write_eof()
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.loop._run_once()
|
self.loop._run_once()
|
||||||
self.assertTrue(self.sock.close.called)
|
self.assertTrue(self.sock.close.called)
|
||||||
tr.close()
|
tr.close()
|
||||||
|
@ -309,7 +309,7 @@ class ProactorSocketTransportTests(test_utils.TestCase):
|
||||||
tr._loop._proactor.send.return_value = f
|
tr._loop._proactor.send.return_value = f
|
||||||
tr.write(b'data')
|
tr.write(b'data')
|
||||||
tr.write_eof()
|
tr.write_eof()
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertFalse(self.sock.shutdown.called)
|
self.assertFalse(self.sock.shutdown.called)
|
||||||
tr._loop._proactor.send.assert_called_with(self.sock, b'data')
|
tr._loop._proactor.send.assert_called_with(self.sock, b'data')
|
||||||
f.set_result(4)
|
f.set_result(4)
|
||||||
|
|
|
@ -698,7 +698,7 @@ class SelectorTransportTests(test_utils.TestCase):
|
||||||
tr = self.create_transport()
|
tr = self.create_transport()
|
||||||
tr.close()
|
tr.close()
|
||||||
|
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertEqual(1, self.loop.remove_reader_count[7])
|
self.assertEqual(1, self.loop.remove_reader_count[7])
|
||||||
self.protocol.connection_lost(None)
|
self.protocol.connection_lost(None)
|
||||||
self.assertEqual(tr._conn_lost, 1)
|
self.assertEqual(tr._conn_lost, 1)
|
||||||
|
@ -723,7 +723,7 @@ class SelectorTransportTests(test_utils.TestCase):
|
||||||
self.loop.add_writer(7, mock.sentinel)
|
self.loop.add_writer(7, mock.sentinel)
|
||||||
tr._force_close(None)
|
tr._force_close(None)
|
||||||
|
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertEqual(tr._buffer, list_to_buffer())
|
self.assertEqual(tr._buffer, list_to_buffer())
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
self.assertFalse(self.loop.writers)
|
self.assertFalse(self.loop.writers)
|
||||||
|
@ -1436,7 +1436,7 @@ class SelectorSslTransportTests(test_utils.TestCase):
|
||||||
tr = self._make_one()
|
tr = self._make_one()
|
||||||
tr.close()
|
tr.close()
|
||||||
|
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertEqual(1, self.loop.remove_reader_count[1])
|
self.assertEqual(1, self.loop.remove_reader_count[1])
|
||||||
self.assertEqual(tr._conn_lost, 1)
|
self.assertEqual(tr._conn_lost, 1)
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class SubprocessTransportTests(test_utils.TestCase):
|
||||||
self.assertTrue(protocol.connection_lost.called)
|
self.assertTrue(protocol.connection_lost.called)
|
||||||
self.assertEqual(protocol.connection_lost.call_args[0], (None,))
|
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._loop)
|
||||||
self.assertIsNone(transport._proc)
|
self.assertIsNone(transport._proc)
|
||||||
self.assertIsNone(transport._protocol)
|
self.assertIsNone(transport._protocol)
|
||||||
|
|
|
@ -440,7 +440,7 @@ class UnixReadPipeTransportTests(test_utils.TestCase):
|
||||||
tr = self.read_pipe_transport()
|
tr = self.read_pipe_transport()
|
||||||
err = object()
|
err = object()
|
||||||
tr._close(err)
|
tr._close(err)
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
test_utils.run_briefly(self.loop)
|
test_utils.run_briefly(self.loop)
|
||||||
self.protocol.connection_lost.assert_called_with(err)
|
self.protocol.connection_lost.assert_called_with(err)
|
||||||
|
@ -598,7 +598,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
|
||||||
tr._read_ready()
|
tr._read_ready()
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
self.assertFalse(self.loop.writers)
|
self.assertFalse(self.loop.writers)
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
test_utils.run_briefly(self.loop)
|
test_utils.run_briefly(self.loop)
|
||||||
self.protocol.connection_lost.assert_called_with(None)
|
self.protocol.connection_lost.assert_called_with(None)
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
|
||||||
self.assertFalse(self.loop.writers)
|
self.assertFalse(self.loop.writers)
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
self.assertEqual([], tr._buffer)
|
self.assertEqual([], tr._buffer)
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
m_logexc.assert_called_with(
|
m_logexc.assert_called_with(
|
||||||
test_utils.MockPattern(
|
test_utils.MockPattern(
|
||||||
'Fatal write error on pipe transport'
|
'Fatal write error on pipe transport'
|
||||||
|
@ -694,7 +694,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
self.assertFalse(self.loop.writers)
|
self.assertFalse(self.loop.writers)
|
||||||
self.assertEqual([], tr._buffer)
|
self.assertEqual([], tr._buffer)
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
test_utils.run_briefly(self.loop)
|
test_utils.run_briefly(self.loop)
|
||||||
self.protocol.connection_lost.assert_called_with(None)
|
self.protocol.connection_lost.assert_called_with(None)
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
|
||||||
def test_write_eof(self):
|
def test_write_eof(self):
|
||||||
tr = self.write_pipe_transport()
|
tr = self.write_pipe_transport()
|
||||||
tr.write_eof()
|
tr.write_eof()
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertFalse(self.loop.readers)
|
self.assertFalse(self.loop.readers)
|
||||||
test_utils.run_briefly(self.loop)
|
test_utils.run_briefly(self.loop)
|
||||||
self.protocol.connection_lost.assert_called_with(None)
|
self.protocol.connection_lost.assert_called_with(None)
|
||||||
|
@ -752,7 +752,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
|
||||||
tr = self.write_pipe_transport()
|
tr = self.write_pipe_transport()
|
||||||
tr._buffer = [b'data']
|
tr._buffer = [b'data']
|
||||||
tr.write_eof()
|
tr.write_eof()
|
||||||
self.assertTrue(tr._closing)
|
self.assertTrue(tr.is_closing())
|
||||||
self.assertFalse(self.protocol.connection_lost.called)
|
self.assertFalse(self.protocol.connection_lost.called)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue