@@ -275,7 +275,7 @@ def close(what=closed):
275
275
if shareable :
276
276
assert len (pool ._shared_cache ) == 0
277
277
cache = []
278
- for i in range (5 ):
278
+ for _i in range (5 ):
279
279
cache .append (pool .connection ())
280
280
assert len (pool ._idle_cache ) == 5
281
281
if shareable :
@@ -297,7 +297,7 @@ def close_shared(what=closed):
297
297
298
298
if shareable :
299
299
cache = []
300
- for i in range (5 ):
300
+ for _i in range (5 ):
301
301
cache .append (pool .connection ())
302
302
pool ._shared_cache [3 ].con .close = close_shared
303
303
else :
@@ -407,63 +407,64 @@ def test_min_max_cached(dbapi, threadsafety): # noqa: F811
407
407
shareable = threadsafety > 1
408
408
pool = PooledDB (dbapi , 3 )
409
409
assert len (pool ._idle_cache ) == 3
410
- cache = [pool .connection () for i in range (3 )]
410
+ cache = [pool .connection () for _i in range (3 )]
411
411
assert len (pool ._idle_cache ) == 0
412
412
assert cache
413
413
del cache
414
414
assert len (pool ._idle_cache ) == 3
415
- cache = [pool .connection () for i in range (6 )]
415
+ cache = [pool .connection () for _i in range (6 )]
416
416
assert len (pool ._idle_cache ) == 0
417
417
assert cache
418
418
del cache
419
419
assert len (pool ._idle_cache ) == 6
420
420
pool = PooledDB (dbapi , 0 , 3 )
421
421
assert len (pool ._idle_cache ) == 0
422
- cache = [pool .connection () for i in range (3 )]
422
+ cache = [pool .connection () for _i in range (3 )]
423
423
assert len (pool ._idle_cache ) == 0
424
424
assert cache
425
425
del cache
426
426
assert len (pool ._idle_cache ) == 3
427
- cache = [pool .connection () for i in range (6 )]
427
+ cache = [pool .connection () for _i in range (6 )]
428
428
assert len (pool ._idle_cache ) == 0
429
429
assert cache
430
430
del cache
431
431
assert len (pool ._idle_cache ) == 3
432
432
pool = PooledDB (dbapi , 3 , 3 )
433
433
assert len (pool ._idle_cache ) == 3
434
- cache = [pool .connection () for i in range (3 )]
434
+ cache = [pool .connection () for _i in range (3 )]
435
435
assert len (pool ._idle_cache ) == 0
436
436
assert cache
437
437
del cache
438
438
assert len (pool ._idle_cache ) == 3
439
- cache = [pool .connection () for i in range (6 )]
439
+ cache = [pool .connection () for _i in range (6 )]
440
440
assert len (pool ._idle_cache ) == 0
441
441
assert cache
442
442
del cache
443
443
assert len (pool ._idle_cache ) == 3
444
444
pool = PooledDB (dbapi , 3 , 2 )
445
445
assert len (pool ._idle_cache ) == 3
446
- cache = [pool .connection () for i in range (4 )]
446
+ cache = [pool .connection () for _i in range (4 )]
447
447
assert len (pool ._idle_cache ) == 0
448
448
assert cache
449
449
del cache
450
450
assert len (pool ._idle_cache ) == 3
451
451
pool = PooledDB (dbapi , 2 , 5 )
452
452
assert len (pool ._idle_cache ) == 2
453
- cache = [pool .connection () for i in range (10 )]
453
+ cache = [pool .connection () for _i in range (10 )]
454
454
assert len (pool ._idle_cache ) == 0
455
455
assert cache
456
456
del cache
457
457
assert len (pool ._idle_cache ) == 5
458
458
pool = PooledDB (dbapi , 1 , 2 , 3 )
459
459
assert len (pool ._idle_cache ) == 1
460
- cache = [pool .connection (False ) for i in range (4 )]
460
+ cache = [pool .connection (False ) for _i in range (4 )]
461
461
assert len (pool ._idle_cache ) == 0
462
462
if shareable :
463
463
assert len (pool ._shared_cache ) == 0
464
+ assert cache
464
465
del cache
465
466
assert len (pool ._idle_cache ) == 2
466
- cache = [pool .connection () for i in range (10 )]
467
+ cache = [pool .connection () for _i in range (10 )]
467
468
assert len (pool ._idle_cache ) == 0
468
469
if shareable :
469
470
assert len (pool ._shared_cache ) == 3
@@ -474,14 +475,14 @@ def test_min_max_cached(dbapi, threadsafety): # noqa: F811
474
475
assert len (pool ._shared_cache ) == 0
475
476
pool = PooledDB (dbapi , 1 , 3 , 2 )
476
477
assert len (pool ._idle_cache ) == 1
477
- cache = [pool .connection (False ) for i in range (4 )]
478
+ cache = [pool .connection (False ) for _i in range (4 )]
478
479
assert len (pool ._idle_cache ) == 0
479
480
if shareable :
480
481
assert len (pool ._shared_cache ) == 0
481
482
assert cache
482
483
del cache
483
484
assert len (pool ._idle_cache ) == 3
484
- cache = [pool .connection () for i in range (10 )]
485
+ cache = [pool .connection () for _i in range (10 )]
485
486
if shareable :
486
487
assert len (pool ._idle_cache ) == 1
487
488
assert len (pool ._shared_cache ) == 2
@@ -500,34 +501,34 @@ def test_max_shared(dbapi, threadsafety): # noqa: F811
500
501
shareable = threadsafety > 1
501
502
pool = PooledDB (dbapi )
502
503
assert len (pool ._idle_cache ) == 0
503
- cache = [pool .connection () for i in range (10 )]
504
+ cache = [pool .connection () for _i in range (10 )]
504
505
assert len (cache ) == 10
505
506
assert len (pool ._idle_cache ) == 0
506
507
pool = PooledDB (dbapi , 1 , 1 , 0 )
507
508
assert len (pool ._idle_cache ) == 1
508
- cache = [pool .connection () for i in range (10 )]
509
+ cache = [pool .connection () for _i in range (10 )]
509
510
assert len (cache ) == 10
510
511
assert len (pool ._idle_cache ) == 0
511
512
pool = PooledDB (dbapi , 0 , 0 , 1 )
512
- cache = [pool .connection () for i in range (10 )]
513
+ cache = [pool .connection () for _i in range (10 )]
513
514
assert len (cache ) == 10
514
515
assert len (pool ._idle_cache ) == 0
515
516
if shareable :
516
517
assert len (pool ._shared_cache ) == 1
517
518
pool = PooledDB (dbapi , 1 , 1 , 1 )
518
519
assert len (pool ._idle_cache ) == 1
519
- cache = [pool .connection () for i in range (10 )]
520
+ cache = [pool .connection () for _i in range (10 )]
520
521
assert len (cache ) == 10
521
522
assert len (pool ._idle_cache ) == 0
522
523
if shareable :
523
524
assert len (pool ._shared_cache ) == 1
524
525
pool = PooledDB (dbapi , 0 , 0 , 7 )
525
- cache = [pool .connection (False ) for i in range (3 )]
526
+ cache = [pool .connection (False ) for _i in range (3 )]
526
527
assert len (cache ) == 3
527
528
assert len (pool ._idle_cache ) == 0
528
529
if shareable :
529
530
assert len (pool ._shared_cache ) == 0
530
- cache = [pool .connection () for i in range (10 )]
531
+ cache = [pool .connection () for _i in range (10 )]
531
532
assert len (cache ) == 10
532
533
assert len (pool ._idle_cache ) == 3
533
534
if shareable :
@@ -537,7 +538,7 @@ def test_max_shared(dbapi, threadsafety): # noqa: F811
537
538
def test_sort_shared (dbapi ): # noqa: F811
538
539
pool = PooledDB (dbapi , 0 , 4 , 4 )
539
540
cache = []
540
- for i in range (6 ):
541
+ for _i in range (6 ):
541
542
db = pool .connection ()
542
543
db .cursor ().execute ('select test' )
543
544
cache .append (db )
@@ -559,7 +560,7 @@ def test_equally_shared(dbapi, threadsafety): # noqa: F811
559
560
shareable = threadsafety > 1
560
561
pool = PooledDB (dbapi , 5 , 5 , 5 )
561
562
assert len (pool ._idle_cache ) == 5
562
- for i in range (15 ):
563
+ for _i in range (15 ):
563
564
db = pool .connection (False )
564
565
db .cursor ().execute ('select test' )
565
566
db .close ()
@@ -569,7 +570,7 @@ def test_equally_shared(dbapi, threadsafety): # noqa: F811
569
570
assert con ._usage == 3
570
571
assert con ._con .num_queries == 3
571
572
cache = []
572
- for i in range (35 ):
573
+ for _i in range (35 ):
573
574
db = pool .connection ()
574
575
db .cursor ().execute ('select test' )
575
576
cache .append (db )
@@ -595,7 +596,7 @@ def test_many_shared(dbapi, threadsafety): # noqa: F811
595
596
shareable = threadsafety > 1
596
597
pool = PooledDB (dbapi , 0 , 0 , 5 )
597
598
cache = []
598
- for i in range (35 ):
599
+ for _i in range (35 ):
599
600
db = pool .connection ()
600
601
db .cursor ().execute ('select test1' )
601
602
db .cursor ().execute ('select test2' )
@@ -622,7 +623,7 @@ def test_many_shared(dbapi, threadsafety): # noqa: F811
622
623
for db in cache :
623
624
if db :
624
625
db .cursor ().callproc ('test4' )
625
- for i in range (6 ):
626
+ for _i in range (6 ):
626
627
db = pool .connection ()
627
628
db .cursor ().callproc ('test4' )
628
629
cache .append (db )
@@ -685,7 +686,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
685
686
assert pool ._connections == 0
686
687
assert len (pool ._idle_cache ) == 1
687
688
cache = []
688
- for i in range (3 ):
689
+ for _i in range (3 ):
689
690
cache .append (pool .connection (False ))
690
691
assert pool ._connections == 3
691
692
assert len (pool ._idle_cache ) == 0
@@ -700,7 +701,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
700
701
assert len (pool ._idle_cache ) == 2
701
702
if shareable :
702
703
assert len (pool ._shared_cache ) == 0
703
- for i in range (3 ):
704
+ for _i in range (3 ):
704
705
cache .append (pool .connection ())
705
706
assert len (pool ._idle_cache ) == 0
706
707
if shareable :
@@ -794,7 +795,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
794
795
assert pool ._connections == 0
795
796
assert len (pool ._idle_cache ) == 4
796
797
cache = []
797
- for i in range (4 ):
798
+ for _i in range (4 ):
798
799
cache .append (pool .connection (False ))
799
800
assert pool ._connections == 4
800
801
assert len (pool ._idle_cache ) == 0
@@ -806,7 +807,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
806
807
assert pool ._maxconnections == 4
807
808
assert pool ._connections == 0
808
809
assert len (pool ._idle_cache ) == 1
809
- for i in range (4 ):
810
+ for _i in range (4 ):
810
811
cache .append (pool .connection ())
811
812
assert len (pool ._idle_cache ) == 0
812
813
if shareable :
@@ -826,7 +827,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
826
827
assert pool ._maxconnections == 3
827
828
assert pool ._connections == 0
828
829
cache = []
829
- for i in range (3 ):
830
+ for _i in range (3 ):
830
831
cache .append (pool .connection (False ))
831
832
assert pool ._connections == 3
832
833
with pytest .raises (TooManyConnections ):
@@ -835,11 +836,11 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
835
836
pool .connection (True )
836
837
cache = []
837
838
assert pool ._connections == 0
838
- for i in range (3 ):
839
+ for _i in range (3 ):
839
840
cache .append (pool .connection ())
840
841
assert pool ._connections == 3
841
842
if shareable :
842
- for i in range (3 ):
843
+ for _i in range (3 ):
843
844
cache .append (pool .connection ())
844
845
assert pool ._connections == 3
845
846
else :
@@ -851,7 +852,7 @@ def test_maxconnections(dbapi, threadsafety): # noqa: F811, PLR0915
851
852
assert pool ._maxconnections == 0
852
853
assert pool ._connections == 0
853
854
cache = []
854
- for i in range (10 ):
855
+ for _i in range (10 ):
855
856
cache .append (pool .connection (False ))
856
857
cache .append (pool .connection ())
857
858
if shareable :
@@ -967,40 +968,40 @@ def test_one_thread_two_connections(dbapi, threadsafety): # noqa: F811
967
968
shareable = threadsafety > 1
968
969
pool = PooledDB (dbapi , 2 )
969
970
db1 = pool .connection ()
970
- for i in range (5 ):
971
+ for _i in range (5 ):
971
972
db1 .cursor ().execute ('select test' )
972
973
db2 = pool .connection ()
973
974
assert db1 != db2
974
975
assert db1 ._con != db2 ._con
975
- for i in range (7 ):
976
+ for _i in range (7 ):
976
977
db2 .cursor ().execute ('select test' )
977
978
assert db1 ._con ._con .num_queries == 5
978
979
assert db2 ._con ._con .num_queries == 7
979
980
del db1
980
981
db1 = pool .connection ()
981
982
assert db1 != db2
982
983
assert db1 ._con != db2 ._con
983
- for i in range (3 ):
984
+ for _i in range (3 ):
984
985
db1 .cursor ().execute ('select test' )
985
986
assert db1 ._con ._con .num_queries == 8
986
987
db2 .cursor ().execute ('select test' )
987
988
assert db2 ._con ._con .num_queries == 8
988
989
pool = PooledDB (dbapi , 0 , 0 , 2 )
989
990
db1 = pool .connection ()
990
- for i in range (5 ):
991
+ for _i in range (5 ):
991
992
db1 .cursor ().execute ('select test' )
992
993
db2 = pool .connection ()
993
994
assert db1 != db2
994
995
assert db1 ._con != db2 ._con
995
- for i in range (7 ):
996
+ for _i in range (7 ):
996
997
db2 .cursor ().execute ('select test' )
997
998
assert db1 ._con ._con .num_queries == 5
998
999
assert db2 ._con ._con .num_queries == 7
999
1000
del db1
1000
1001
db1 = pool .connection ()
1001
1002
assert db1 != db2
1002
1003
assert db1 ._con != db2 ._con
1003
- for i in range (3 ):
1004
+ for _i in range (3 ):
1004
1005
db1 .cursor ().execute ('select test' )
1005
1006
assert db1 ._con ._con .num_queries == 8
1006
1007
db2 .cursor ().execute ('select test' )
@@ -1028,7 +1029,7 @@ def test_three_threads_two_connections(dbapi, threadsafety): # noqa: F811
1028
1029
def connection ():
1029
1030
queue .put (pool .connection (), timeout = 1 )
1030
1031
1031
- for i in range (3 ):
1032
+ for _i in range (3 ):
1032
1033
Thread (target = connection ).start ()
1033
1034
db1 = queue .get (timeout = 1 )
1034
1035
db2 = queue .get (timeout = 1 )
0 commit comments