Skip to content

Commit

Permalink
Attempt to apply eventlet monkey patch workaround for issue eventlet/…
Browse files Browse the repository at this point in the history
  • Loading branch information
nzlosh committed Apr 1, 2020
1 parent 75e2645 commit 25a7896
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions st2common/st2common/util/monkey_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def monkey_patch(patch_thread=None):

eventlet.monkey_patch(os=True, select=True, socket=True, thread=patch_thread, time=True)

# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading
orig_threading.current_thread.__globals__['_active'] = threading._active

def use_select_poll_workaround(nose_only=True):
"""
Expand Down
6 changes: 6 additions & 0 deletions st2stream/st2stream/cmd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
thread=False if '--use-debugger' in sys.argv else True,
time=True)

# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading
orig_threading.current_thread.__globals__['_active'] = threading._active

LOG = logging.getLogger(__name__)

# How much time to give to the request in progress to finish in seconds before killing them
Expand Down
6 changes: 6 additions & 0 deletions st2tests/st2tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
from st2common.util.monkey_patch import monkey_patch
monkey_patch()

# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading
orig_threading.current_thread.__globals__['_active'] = threading._active

try:
import simplejson as json
except ImportError:
Expand Down

0 comments on commit 25a7896

Please sign in to comment.