diff --git a/doc/src/advanced.rst b/doc/src/advanced.rst index 993f29f0..ff0137d0 100644 --- a/doc/src/advanced.rst +++ b/doc/src/advanced.rst @@ -12,7 +12,7 @@ More advanced topics conn.commit() def wait(conn): - while 1: + while True: state = conn.poll() if state == psycopg2.extensions.POLL_OK: break @@ -285,7 +285,7 @@ something to read:: curs.execute("LISTEN test;") print "Waiting for notifications on channel 'test'" - while 1: + while True: if select.select([conn],[],[],5) == ([],[],[]): print "Timeout" else: @@ -347,7 +347,7 @@ together with the Python :py:func:`~select.select` function in order to carry on asynchronous operations with Psycopg:: def wait(conn): - while 1: + while True: state = conn.poll() if state == psycopg2.extensions.POLL_OK: break @@ -468,7 +468,7 @@ example callback (using `!select()` to block) is provided as `psycopg2.extras.wait_select()`: it boils down to something similar to:: def wait_select(conn): - while 1: + while True: state = conn.poll() if state == extensions.POLL_OK: break diff --git a/lib/extras.py b/lib/extras.py index 0ae2582e..94fee28e 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -116,7 +116,7 @@ class DictCursorBase(_cursor): first = next(res) yield first - while 1: + while True: yield next(res) except StopIteration: return @@ -378,7 +378,7 @@ class NamedTupleCursor(_cursor): yield nt._make(t) - while 1: + while True: yield nt._make(next(it)) except StopIteration: return @@ -773,7 +773,7 @@ def wait_select(conn): import select from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE - while 1: + while True: try: state = conn.poll() if state == POLL_OK: @@ -1172,7 +1172,7 @@ def _paginate(seq, page_size): """ page = [] it = iter(seq) - while 1: + while True: try: for i in range(page_size): page.append(next(it)) diff --git a/tests/test_green.py b/tests/test_green.py index 0ef37ff4..424c4f99 100755 --- a/tests/test_green.py +++ b/tests/test_green.py @@ -134,7 +134,7 @@ class CallbackErrorTestCase(ConnectingTestCase): import select from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE - while 1: + while True: if self.to_error is not None: self.to_error -= 1 if self.to_error <= 0: