summaryrefslogtreecommitdiff
path: root/distbuild/jm.py
diff options
context:
space:
mode:
Diffstat (limited to 'distbuild/jm.py')
-rw-r--r--distbuild/jm.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/distbuild/jm.py b/distbuild/jm.py
index 615100e4..0d0bc09d 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, 2014-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
@@ -39,8 +39,17 @@ class JsonNewMessage(object):
class JsonEof(object):
pass
-
-
+
+
+class JsonError(object):
+
+ '''An error has occured with a socket used for communication.'''
+
+ def __init__(self, sock, exception):
+ self.sock = sock
+ self.exception = exception
+
+
class _Close2(object):
pass
@@ -72,9 +81,12 @@ class JsonMachine(StateMachine):
# state, source, event_class, new_state, callback
('rw', sockbuf, SocketBufferNewData, 'rw', self._parse),
('rw', sockbuf, SocketBufferEof, 'w', self._send_eof),
+ ('rw', sockbuf, SocketError, 'error', self._send_error),
('rw', self, _Close2, None, self._really_close),
('w', self, _Close2, None, self._really_close),
+
+ ('error', self, _Close2, None, self._really_close)
]
self.add_transitions(spec)
@@ -115,6 +127,9 @@ class JsonMachine(StateMachine):
def _send_eof(self, event_source, event):
self.mainloop.queue_event(self, JsonEof())
+ def _send_error(self, event_source, event):
+ self.mainloop.queue_event(self, JsonError(event.sock, event.exception))
+
def _really_close(self, event_source, event):
self.sockbuf.close()
self._send_eof(event_source, event)