summaryrefslogtreecommitdiff
path: root/distbuild/jm.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-02-04 11:49:13 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-02-04 11:49:13 +0000
commitb407d3e410bb120f9bae53cd7f860153827f5abc (patch)
tree1b33e0b85949f0308fb82368662b0be67035304e /distbuild/jm.py
parentc97bb00cf30c5e2032cedfb25403acda98ef4a02 (diff)
parent9ae7b0e248e2c4738e66d3820173cf8bb6d6d6eb (diff)
downloadmorph-b407d3e410bb120f9bae53cd7f860153827f5abc.tar.gz
Merge remote-tracking branch 'lauren/baserock/lauren/distbuild-invalid-input-crash' into sam/distbuild-testssam/distbuild-tests
Diffstat (limited to 'distbuild/jm.py')
-rw-r--r--distbuild/jm.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/distbuild/jm.py b/distbuild/jm.py
index 5592d5bd..0b290e5c 100644
--- a/distbuild/jm.py
+++ b/distbuild/jm.py
@@ -1,6 +1,6 @@
# mainloop/jm.py -- state machine for JSON communication between nodes
#
-# Copyright (C) 2012, 2014 Codethink Limited
+# Copyright (C) 2012, 2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -105,8 +105,13 @@ class JsonMachine(StateMachine):
line = line.rstrip()
if self.debug_json:
logging.debug('JsonMachine: line: %s' % repr(line))
- msg = yaml.load(json.loads(line))
- self.mainloop.queue_event(self, JsonNewMessage(msg))
+ msg = None
+ try:
+ msg = yaml.safe_load(json.loads(line))
+ except Exception:
+ logging.error('Invalid input: %s' % line)
+ if msg:
+ self.mainloop.queue_event(self, JsonNewMessage(msg))
def _send_eof(self, event_source, event):
self.mainloop.queue_event(self, JsonEof())