mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-11-15 06:40:38 -05:00
Move more xrange to six
plus a bonus next() Signed-off-by: Adrian Tschira <nota@notafile.com>
This commit is contained in:
parent
9558236728
commit
d82b6ea9e6
9 changed files with 28 additions and 11 deletions
|
|
@ -27,6 +27,8 @@ from contextlib import contextmanager
|
|||
|
||||
import logging
|
||||
|
||||
from six.moves import range
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -158,13 +160,13 @@ def concurrently_execute(func, args, limit):
|
|||
def _concurrently_execute_inner():
|
||||
try:
|
||||
while True:
|
||||
yield func(it.next())
|
||||
yield func(next(it))
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
return logcontext.make_deferred_yieldable(defer.gatherResults([
|
||||
preserve_fn(_concurrently_execute_inner)()
|
||||
for _ in xrange(limit)
|
||||
for _ in range(limit)
|
||||
], consumeErrors=True)).addErrback(unwrapFirstError)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import random
|
||||
import string
|
||||
from six.moves import range
|
||||
|
||||
_string_with_symbols = (
|
||||
string.digits + string.ascii_letters + ".,;:^&*-_+=#~@"
|
||||
|
|
@ -22,12 +23,12 @@ _string_with_symbols = (
|
|||
|
||||
|
||||
def random_string(length):
|
||||
return ''.join(random.choice(string.ascii_letters) for _ in xrange(length))
|
||||
return ''.join(random.choice(string.ascii_letters) for _ in range(length))
|
||||
|
||||
|
||||
def random_string_with_symbols(length):
|
||||
return ''.join(
|
||||
random.choice(_string_with_symbols) for _ in xrange(length)
|
||||
random.choice(_string_with_symbols) for _ in range(length)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from six.moves import range
|
||||
|
||||
|
||||
class _Entry(object):
|
||||
__slots__ = ["end_key", "queue"]
|
||||
|
|
@ -68,7 +70,7 @@ class WheelTimer(object):
|
|||
# Add empty entries between the end of the current list and when we want
|
||||
# to insert. This ensures there are no gaps.
|
||||
self.entries.extend(
|
||||
_Entry(key) for key in xrange(last_key, then_key + 1)
|
||||
_Entry(key) for key in range(last_key, then_key + 1)
|
||||
)
|
||||
|
||||
self.entries[-1].queue.append(obj)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue