Add python-eventlet package to MOS 9.0 repository
[packages/trusty/python-eventlet.git] / python-eventlet / tests / isolated / patcher_socketserver_selectors.py
1 __test__ = False
2
3 if __name__ == '__main__':
4     import eventlet
5     eventlet.monkey_patch()
6
7     from eventlet.support.six.moves.BaseHTTPServer import (
8         HTTPServer,
9         BaseHTTPRequestHandler,
10     )
11     import threading
12
13     server = HTTPServer(('localhost', 0), BaseHTTPRequestHandler)
14     thread = threading.Thread(target=server.serve_forever)
15
16     # Before fixing it the code would never go pass this line because:
17     # * socketserver.BaseServer that's used behind the scenes here uses
18     #   selectors.PollSelector if it's available and we don't have green poll
19     #   implementation so this just couldn't work
20     # * making socketserver use selectors.SelectSelector wasn't enough as
21     #   until now we just failed to monkey patch selectors module
22     #
23     # Due to the issues above this thread.start() call effectively behaved
24     # like calling server.serve_forever() directly in the current thread
25     #
26     # Original report: https://github.com/eventlet/eventlet/issues/249
27     thread.start()
28
29     server.shutdown()
30     print('pass')