summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakub Stasiak <jakub@stasiak.at>2015-11-12 02:05:25 +0100
committerJakub Stasiak <jakub@stasiak.at>2016-01-06 23:57:05 +0100
commit0d509ef7d2eea3ed4f8ade35d5d09918c811b56c (patch)
treee630ceeaf0e7f77aaa9a464cdb844f5fe7f0bb22 /tests
parent3ae710e70ecb3683f83b9829011de01b5d3e0bf4 (diff)
downloadeventlet-0d509ef7d2eea3ed4f8ade35d5d09918c811b56c.tar.gz
Fix HTTPServer.serve_forever blocking whole process
Original report: https://github.com/eventlet/eventlet/issues/249 Explanation is in the comments in the code. Originally reverted[1] because a commit preceding it[2] broke the build but it wasn't clear what commit was responsible. [1] 02b693a45db96bd2baf27c1d5128a8bcedb8fbfc [2] 4656eadfa5ae1237036a63ad4004dbee4572debf
Diffstat (limited to 'tests')
-rw-r--r--tests/isolated/patcher_socketserver_selectors.py28
-rw-r--r--tests/patcher_test.py4
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/isolated/patcher_socketserver_selectors.py b/tests/isolated/patcher_socketserver_selectors.py
new file mode 100644
index 0000000..97df6e2
--- /dev/null
+++ b/tests/isolated/patcher_socketserver_selectors.py
@@ -0,0 +1,28 @@
+if __name__ == '__main__':
+ import eventlet
+ eventlet.monkey_patch()
+
+ from eventlet.support.six.moves.BaseHTTPServer import (
+ HTTPServer,
+ BaseHTTPRequestHandler,
+ )
+ import threading
+
+ server = HTTPServer(('localhost', 0), BaseHTTPRequestHandler)
+ thread = threading.Thread(target=server.serve_forever)
+
+ # Before fixing it the code would never go pass this line because:
+ # * socketserver.BaseServer that's used behind the scenes here uses
+ # selectors.PollSelector if it's available and we don't have green poll
+ # implementation so this just couldn't work
+ # * making socketserver use selectors.SelectSelector wasn't enough as
+ # until now we just failed to monkey patch selectors module
+ #
+ # Due to the issues above this thread.start() call effectively behaved
+ # like calling server.serve_forever() directly in the current thread
+ #
+ # Original report: https://github.com/eventlet/eventlet/issues/249
+ thread.start()
+
+ server.shutdown()
+ print('pass')
diff --git a/tests/patcher_test.py b/tests/patcher_test.py
index 2e458c5..deae8ef 100644
--- a/tests/patcher_test.py
+++ b/tests/patcher_test.py
@@ -506,3 +506,7 @@ def test_threading_condition():
def test_threading_join():
tests.run_isolated('patcher_threading_join.py')
+
+
+def test_socketserver_selectors():
+ tests.run_isolated('patcher_socketserver_selectors.py')