summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-10-18 14:58:20 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-10-18 14:58:20 (GMT)
commit57497ad1810304ef74774fb1abd379dec80f458b (patch)
tree1696f5389cdad967002eff56160765936aba9010
parent40b22d0661c45ac350a7252a32ef665b81b1643c (diff)
downloadcpython-57497ad1810304ef74774fb1abd379dec80f458b.zip
cpython-57497ad1810304ef74774fb1abd379dec80f458b.tar.gz
cpython-57497ad1810304ef74774fb1abd379dec80f458b.tar.bz2
Rename Transport.pause/resume to pause_reading/pause_writing. Also relax timeout in test_call_later().
-rw-r--r--Lib/asyncio/proactor_events.py6
-rw-r--r--Lib/asyncio/selector_events.py14
-rw-r--r--Lib/asyncio/streams.py4
-rw-r--r--Lib/asyncio/transports.py6
-rw-r--r--Lib/asyncio/unix_events.py4
-rw-r--r--Lib/test/test_asyncio/test_events.py2
-rw-r--r--Lib/test/test_asyncio/test_proactor_events.py6
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py12
-rw-r--r--Lib/test/test_asyncio/test_transports.py4
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py8
10 files changed, 33 insertions, 33 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index c1347b7..665569f 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -94,12 +94,12 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport,
self._paused = False
self._loop.call_soon(self._loop_reading)
- def pause(self):
- assert not self._closing, 'Cannot pause() when closing'
+ def pause_reading(self):
+ assert not self._closing, 'Cannot pause_reading() when closing'
assert not self._paused, 'Already paused'
self._paused = True
- def resume(self):
+ def resume_reading(self):
assert self._paused, 'Not paused'
self._paused = False
if self._closing:
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index e8ae885..2edac65 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -406,13 +406,13 @@ class _SelectorSocketTransport(_SelectorTransport):
if waiter is not None:
self._loop.call_soon(waiter.set_result, None)
- def pause(self):
- assert not self._closing, 'Cannot pause() when closing'
+ def pause_reading(self):
+ assert not self._closing, 'Cannot pause_reading() when closing'
assert not self._paused, 'Already paused'
self._paused = True
self._loop.remove_reader(self._sock_fd)
- def resume(self):
+ def resume_reading(self):
assert self._paused, 'Not paused'
self._paused = False
if self._closing:
@@ -590,19 +590,19 @@ class _SelectorSslTransport(_SelectorTransport):
if self._waiter is not None:
self._loop.call_soon(self._waiter.set_result, None)
- def pause(self):
+ def pause_reading(self):
# XXX This is a bit icky, given the comment at the top of
# _on_ready(). Is it possible to evoke a deadlock? I don't
# know, although it doesn't look like it; write() will still
# accept more data for the buffer and eventually the app will
- # call resume() again, and things will flow again.
+ # call resume_reading() again, and things will flow again.
- assert not self._closing, 'Cannot pause() when closing'
+ assert not self._closing, 'Cannot pause_reading() when closing'
assert not self._paused, 'Already paused'
self._paused = True
self._loop.remove_reader(self._sock_fd)
- def resume(self):
+ def resume_reading(self):
assert self._paused, 'Not paused'
self._paused = False
if self._closing:
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index d0f12e8..9915aa5 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -106,7 +106,7 @@ class StreamReader:
def _maybe_resume_transport(self):
if self._paused and self.byte_count <= self.limit:
self._paused = False
- self._transport.resume()
+ self._transport.resume_reading()
def feed_eof(self):
self.eof = True
@@ -133,7 +133,7 @@ class StreamReader:
not self._paused and
self.byte_count > 2*self.limit):
try:
- self._transport.pause()
+ self._transport.pause_reading()
except NotImplementedError:
# The transport can't be paused.
# We'll just have to buffer all data.
diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py
index bf3adee..f1a7180 100644
--- a/Lib/asyncio/transports.py
+++ b/Lib/asyncio/transports.py
@@ -29,15 +29,15 @@ class BaseTransport:
class ReadTransport(BaseTransport):
"""ABC for read-only transports."""
- def pause(self):
+ def pause_reading(self):
"""Pause the receiving end.
No data will be passed to the protocol's data_received()
- method until resume() is called.
+ method until resume_reading() is called.
"""
raise NotImplementedError
- def resume(self):
+ def resume_reading(self):
"""Resume the receiving end.
Data received will once again be passed to the protocol's
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 34b2aea..a234f4f 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -232,10 +232,10 @@ class _UnixReadPipeTransport(transports.ReadTransport):
self._loop.call_soon(self._protocol.eof_received)
self._loop.call_soon(self._call_connection_lost, None)
- def pause(self):
+ def pause_reading(self):
self._loop.remove_reader(self._fileno)
- def resume(self):
+ def resume_reading(self):
self._loop.add_reader(self._fileno, self._read_ready)
def close(self):
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index a9a9271..2e89f72 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -238,7 +238,7 @@ class EventLoopTestsMixin:
self.loop.run_forever()
t1 = time.monotonic()
self.assertEqual(results, ['hello world'])
- self.assertTrue(0.09 <= t1-t0 <= 0.12, t1-t0)
+ self.assertTrue(0.08 <= t1-t0 <= 0.2, t1-t0)
def test_call_soon(self):
results = []
diff --git a/Lib/test/test_asyncio/test_proactor_events.py b/Lib/test/test_asyncio/test_proactor_events.py
index e4dd609..05d1606 100644
--- a/Lib/test/test_asyncio/test_proactor_events.py
+++ b/Lib/test/test_asyncio/test_proactor_events.py
@@ -308,7 +308,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
tr.write_eof()
tr.close()
- def test_pause_resume(self):
+ def test_pause_resume_reading(self):
tr = _ProactorSocketTransport(
self.loop, self.sock, self.protocol)
futures = []
@@ -323,12 +323,12 @@ class ProactorSocketTransportTests(unittest.TestCase):
self.protocol.data_received.assert_called_with(b'data1')
self.loop._run_once()
self.protocol.data_received.assert_called_with(b'data2')
- tr.pause()
+ tr.pause_reading()
self.assertTrue(tr._paused)
for i in range(10):
self.loop._run_once()
self.protocol.data_received.assert_called_with(b'data2')
- tr.resume()
+ tr.resume_reading()
self.assertFalse(tr._paused)
self.loop._run_once()
self.protocol.data_received.assert_called_with(b'data3')
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index 1465cd2..53728b8 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -676,15 +676,15 @@ class SelectorSocketTransportTests(unittest.TestCase):
test_utils.run_briefly(self.loop)
self.assertIsNone(fut.result())
- def test_pause_resume(self):
+ def test_pause_resume_reading(self):
tr = _SelectorSocketTransport(
self.loop, self.sock, self.protocol)
self.assertFalse(tr._paused)
self.loop.assert_reader(7, tr._read_ready)
- tr.pause()
+ tr.pause_reading()
self.assertTrue(tr._paused)
self.assertFalse(7 in self.loop.readers)
- tr.resume()
+ tr.resume_reading()
self.assertFalse(tr._paused)
self.loop.assert_reader(7, tr._read_ready)
@@ -1044,14 +1044,14 @@ class SelectorSslTransportTests(unittest.TestCase):
self.assertTrue(transport._waiter.done())
self.assertIs(exc, transport._waiter.exception())
- def test_pause_resume(self):
+ def test_pause_resume_reading(self):
tr = self._make_one()
self.assertFalse(tr._paused)
self.loop.assert_reader(1, tr._on_ready)
- tr.pause()
+ tr.pause_reading()
self.assertTrue(tr._paused)
self.assertFalse(1 in self.loop.readers)
- tr.resume()
+ tr.resume_reading()
self.assertFalse(tr._paused)
self.loop.assert_reader(1, tr._on_ready)
diff --git a/Lib/test/test_asyncio/test_transports.py b/Lib/test/test_asyncio/test_transports.py
index fce2e6f..53071af 100644
--- a/Lib/test/test_asyncio/test_transports.py
+++ b/Lib/test/test_asyncio/test_transports.py
@@ -33,8 +33,8 @@ class TransportTests(unittest.TestCase):
self.assertRaises(NotImplementedError, transport.write, 'data')
self.assertRaises(NotImplementedError, transport.write_eof)
self.assertRaises(NotImplementedError, transport.can_write_eof)
- self.assertRaises(NotImplementedError, transport.pause)
- self.assertRaises(NotImplementedError, transport.resume)
+ self.assertRaises(NotImplementedError, transport.pause_reading)
+ self.assertRaises(NotImplementedError, transport.resume_reading)
self.assertRaises(NotImplementedError, transport.close)
self.assertRaises(NotImplementedError, transport.abort)
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index 227366d..ccabeea 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -375,21 +375,21 @@ class UnixReadPipeTransportTests(unittest.TestCase):
m_logexc.assert_called_with('Fatal error for %s', tr)
@unittest.mock.patch('os.read')
- def test_pause(self, m_read):
+ def test_pause_reading(self, m_read):
tr = unix_events._UnixReadPipeTransport(
self.loop, self.pipe, self.protocol)
m = unittest.mock.Mock()
self.loop.add_reader(5, m)
- tr.pause()
+ tr.pause_reading()
self.assertFalse(self.loop.readers)
@unittest.mock.patch('os.read')
- def test_resume(self, m_read):
+ def test_resume_reading(self, m_read):
tr = unix_events._UnixReadPipeTransport(
self.loop, self.pipe, self.protocol)
- tr.resume()
+ tr.resume_reading()
self.loop.assert_reader(5, tr._read_ready)
@unittest.mock.patch('os.read')