File: env_tpool_size.py

package info (click to toggle)
python-eventlet 0.26.1-7%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,916 kB
  • sloc: python: 24,898; makefile: 98
file content (26 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
__test__ = False

if __name__ == '__main__':
    import sys
    import time
    from eventlet import tpool
    import eventlet

    current = [0]
    highwater = [0]

    def count():
        current[0] += 1
        time.sleep(0.01)
        if current[0] > highwater[0]:
            highwater[0] = current[0]
        current[0] -= 1

    expected = int(sys.argv[1])
    normal = int(sys.argv[2])
    p = eventlet.GreenPool()
    for i in range(expected * 2):
        p.spawn(tpool.execute, count)
    p.waitall()
    assert highwater[0] > normal, "Highwater %s <= %s" % (highwater[0], normal)
    print('pass')