File: patcher_threading_current.py

package info (click to toggle)
python-eventlet 0.40.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,200 kB
  • sloc: python: 25,101; sh: 78; makefile: 31
file content (25 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (3)
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
# Threading.current_thread does not change when using greenthreads?
# https://github.com/eventlet/eventlet/issues/172
__test__ = False

if __name__ == '__main__':
    import eventlet
    eventlet.monkey_patch()

    import threading

    g = set()

    def fun():
        ct = threading.current_thread()
        g.add(ct.name)

    ts = tuple(threading.Thread(target=fun, name='t{}'.format(i)) for i in range(3))
    for t in ts:
        t.start()
    for t in ts:
        t.join()

    assert g == {'t0', 't1', 't2'}, repr(g)

    print('pass')