Merge "Call monkey_patch before other modules are loaded" into stable/grizzly
Jenkins authored 10 years ago
Gerrit Code Review committed 10 years ago
21 | 21 |
Glance API Server
|
22 | 22 |
"""
|
23 | 23 |
|
|
24 |
import eventlet
|
24 | 25 |
import gettext
|
25 | 26 |
import os
|
26 | 27 |
import sys
|
|
28 |
|
|
29 |
# Monkey patch socket and time
|
|
30 |
eventlet.patcher.monkey_patch(all=False, socket=True, time=True)
|
27 | 31 |
|
28 | 32 |
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
29 | 33 |
# it will override what happens to be installed in /usr/(local/)lib/python...
|
21 | 21 |
Reference implementation server for Glance Registry
|
22 | 22 |
"""
|
23 | 23 |
|
|
24 |
import eventlet
|
24 | 25 |
import gettext
|
25 | 26 |
import os
|
26 | 27 |
import sys
|
|
28 |
|
|
29 |
# Monkey patch socket and time
|
|
30 |
eventlet.patcher.monkey_patch(all=False, socket=True, time=True)
|
27 | 31 |
|
28 | 32 |
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
29 | 33 |
# it will override what happens to be installed in /usr/(local/)lib/python...
|
218 | 218 |
self.run_child()
|
219 | 219 |
|
220 | 220 |
def create_pool(self):
|
221 | |
eventlet.patcher.monkey_patch(all=False, socket=True, time=True)
|
222 | 221 |
return eventlet.GreenPool(size=self.threads)
|
223 | 222 |
|
224 | 223 |
def wait_on_children(self):
|
246 | 246 |
self.assertEqual(v, result[k])
|
247 | 247 |
else:
|
248 | 248 |
self.assertFalse(k in result)
|
249 | |
|
250 | |
|
251 | |
class TestMonkeyPatch(test_utils.BaseTestCase):
|
252 | |
|
253 | |
def test_time_is_monkey_patched(self):
|
254 | |
"""
|
255 | |
Test GET with no redirect
|
256 | |
"""
|
257 | |
server = wsgi.Server()
|
258 | |
server.create_pool()
|
259 | |
self.assertTrue(eventlet.patcher.is_monkey_patched(time))
|
260 | |
self.assertTrue(eventlet.patcher.is_monkey_patched(socket))
|