Skip to content

Commit

Permalink
Monkey patch original current_thread _active
Browse files Browse the repository at this point in the history
Monkey patch the original current_thread to use the up-to-date _active
global variable. This solution is based on that documented at:
eventlet/eventlet#592

Change-Id: I35335325828c10f7a0a1c97edfd1a842dda77577
Story: 2007614
  • Loading branch information
Corey Bryant authored and dmendiza committed Mar 19, 2021
1 parent 97ae3bc commit 14e3ab9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions barbican/cmd/keystone_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
# To have remote debugging, thread module needs to be disabled.
# eventlet.monkey_patch(thread=False)
eventlet.monkey_patch()
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active


# 'Borrowed' from the Glance project:
Expand Down
6 changes: 6 additions & 0 deletions barbican/cmd/retry_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

# Oslo messaging RPC server uses eventlet.
eventlet.monkey_patch()
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active

# 'Borrowed' from the Glance project:
# If ../barbican/__init__.py exists, add ../ to Python search path, so that
Expand Down
6 changes: 6 additions & 0 deletions barbican/cmd/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

# Oslo messaging RPC server uses eventlet.
eventlet.monkey_patch()
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active

# 'Borrowed' from the Glance project:
# If ../barbican/__init__.py exists, add ../ to Python search path, so that
Expand Down

0 comments on commit 14e3ab9

Please sign in to comment.