Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge "Workaround for TypeError in zerorpc Events.__del__"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Feb 26, 2016
2 parents 8d19958 + e4165f5 commit 086a3e2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion solar/orchestration/executors/zerorpc_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.

import gevent
import sys

import gevent
from functools import update_wrapper

# NOTE(jnowak): this is a workaround for bug in zerorpc.gevent_zmq
# it's broken on gevent patched environments and when
Expand All @@ -23,6 +24,7 @@
if tuple(map(int, zmq.__version__.split('.'))) > (13, 0, 2):
sys.modules['zmq'] = zmq
else:
del sys.modules['zmq']
del zmq

# NOTE(jnowak): NOQA because of workaround above (E402)
Expand All @@ -32,6 +34,24 @@
from solar.orchestration.executors import base # NOQA


# NOTE(jnowak): this is there because of __del__ in zerorpc Events
# without that patch you may have:
# TypeError("'NoneType' object is not callable",)
# during interpreter shutdown
# see #1549384 bug for more info
def patch_events():
def fixed_del(obj):
try:
obj.__orig_del__()
except TypeError:
pass
update_wrapper(fixed_del, zerorpc.events.Events.__del__)
zerorpc.events.Events.__orig_del__ = zerorpc.events.Events.__del__
zerorpc.events.Events.__del__ = fixed_del

patch_events()


class PoolBasedPuller(zerorpc.Puller):
"""ImprovedPuller allows to control pool of gevent threads and
track assignments of gevent threads
Expand Down

0 comments on commit 086a3e2

Please sign in to comment.