Ticket #283: test_exit.py
| File test_exit.py, 457 bytes (added by ghazel, 4 years ago) |
|---|
| Line | |
|---|---|
| 1 | import os |
| 2 | import time |
| 3 | import socket |
| 4 | import threading |
| 5 | |
| 6 | |
| 7 | def 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 | |
| 14 | s = socket.socket() |
| 15 | s.bind(('0.0.0.0', 13579)) |
| 16 | s.listen(5) |
| 17 | s.settimeout(3) |
| 18 | |
| 19 | threading.Thread(target=child).start() |
| 20 | |
| 21 | while 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 |
