mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 00:46:33 +03:00
Convert while 1:
statements to while True:
A slightly more readable and modern syntax.
This commit is contained in:
parent
18f5d5ad05
commit
03bb44dd2c
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user