mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-07-02 02:33:06 +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()
|
conn.commit()
|
||||||
|
|
||||||
def wait(conn):
|
def wait(conn):
|
||||||
while 1:
|
while True:
|
||||||
state = conn.poll()
|
state = conn.poll()
|
||||||
if state == psycopg2.extensions.POLL_OK:
|
if state == psycopg2.extensions.POLL_OK:
|
||||||
break
|
break
|
||||||
|
@ -285,7 +285,7 @@ something to read::
|
||||||
curs.execute("LISTEN test;")
|
curs.execute("LISTEN test;")
|
||||||
|
|
||||||
print "Waiting for notifications on channel 'test'"
|
print "Waiting for notifications on channel 'test'"
|
||||||
while 1:
|
while True:
|
||||||
if select.select([conn],[],[],5) == ([],[],[]):
|
if select.select([conn],[],[],5) == ([],[],[]):
|
||||||
print "Timeout"
|
print "Timeout"
|
||||||
else:
|
else:
|
||||||
|
@ -347,7 +347,7 @@ together with the Python :py:func:`~select.select` function in order to carry on
|
||||||
asynchronous operations with Psycopg::
|
asynchronous operations with Psycopg::
|
||||||
|
|
||||||
def wait(conn):
|
def wait(conn):
|
||||||
while 1:
|
while True:
|
||||||
state = conn.poll()
|
state = conn.poll()
|
||||||
if state == psycopg2.extensions.POLL_OK:
|
if state == psycopg2.extensions.POLL_OK:
|
||||||
break
|
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::
|
`psycopg2.extras.wait_select()`: it boils down to something similar to::
|
||||||
|
|
||||||
def wait_select(conn):
|
def wait_select(conn):
|
||||||
while 1:
|
while True:
|
||||||
state = conn.poll()
|
state = conn.poll()
|
||||||
if state == extensions.POLL_OK:
|
if state == extensions.POLL_OK:
|
||||||
break
|
break
|
||||||
|
|
|
@ -116,7 +116,7 @@ class DictCursorBase(_cursor):
|
||||||
first = next(res)
|
first = next(res)
|
||||||
|
|
||||||
yield first
|
yield first
|
||||||
while 1:
|
while True:
|
||||||
yield next(res)
|
yield next(res)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
|
@ -378,7 +378,7 @@ class NamedTupleCursor(_cursor):
|
||||||
|
|
||||||
yield nt._make(t)
|
yield nt._make(t)
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
yield nt._make(next(it))
|
yield nt._make(next(it))
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
|
@ -773,7 +773,7 @@ def wait_select(conn):
|
||||||
import select
|
import select
|
||||||
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
|
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
state = conn.poll()
|
state = conn.poll()
|
||||||
if state == POLL_OK:
|
if state == POLL_OK:
|
||||||
|
@ -1172,7 +1172,7 @@ def _paginate(seq, page_size):
|
||||||
"""
|
"""
|
||||||
page = []
|
page = []
|
||||||
it = iter(seq)
|
it = iter(seq)
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
for i in range(page_size):
|
for i in range(page_size):
|
||||||
page.append(next(it))
|
page.append(next(it))
|
||||||
|
|
|
@ -134,7 +134,7 @@ class CallbackErrorTestCase(ConnectingTestCase):
|
||||||
import select
|
import select
|
||||||
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
|
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
if self.to_error is not None:
|
if self.to_error is not None:
|
||||||
self.to_error -= 1
|
self.to_error -= 1
|
||||||
if self.to_error <= 0:
|
if self.to_error <= 0:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user