This fixes an issue where various parts of the system could get stuck

waiting to emit a socketio event if there was a problem with the
websocket service.  Instead of crashing and hanging the system it will
now emit an error and continue.
This commit is contained in:
Matthew Jones
2015-04-21 15:29:37 -04:00
parent 93ecf739be
commit 0fc753046d
2 changed files with 16 additions and 8 deletions

View File

@@ -24,6 +24,7 @@ from django.utils.encoding import smart_str
# PyCrypto
from Crypto.Cipher import AES
logger = logging.getLogger('awx.main.utils')
__all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
'get_ansible_version', 'get_awx_version', 'update_scm_url',
@@ -380,10 +381,13 @@ def get_system_task_capacity():
def emit_websocket_notification(endpoint, event, payload):
from awx.main.socket import Socket
with Socket('websocket', 'w') as websocket:
payload['event'] = event
payload['endpoint'] = endpoint
websocket.publish(payload)
try:
with Socket('websocket', 'w', nowait=True, logger=logger) as websocket:
payload['event'] = event
payload['endpoint'] = endpoint
websocket.publish(payload)
except Exception as ex:
pass
_inventory_updates = threading.local()