Ticket #283: test_exit.py

File test_exit.py, 457 bytes (added by ghazel, 4 years ago)
Line 
1import os
2import time
3import socket
4import threading
5
6
7def child():
8    # give it enough time to get in to accept()
9    time.sleep(1)
10    print "trying to exit..."
11    os._exit(3)
12
13
14s = socket.socket()
15s.bind(('0.0.0.0', 13579))
16s.listen(5)
17s.settimeout(3)
18
19threading.Thread(target=child).start()
20
21while 1:
22    print "in accept"
23    try:
24        r = s.accept()
25    except Exception, e:
26        print "accept err", e
27    else:
28        print "out accept", r
29