http://hg.viff.dk/viff/rev/0e3d8a3d3b15
changeset: 1171:0e3d8a3d3b15
user: Martin Geisler <[email protected]>
date: Thu Apr 23 11:21:37 2009 +0200
summary: Add abort method in Runtime to deal with bad data.
diffstat:
1 file changed, 14 insertions(+), 1 deletion(-)
viff/runtime.py | 15 ++++++++++++++-
diffs (32 lines):
diff -r 98eb6e0cfa88 -r 0e3d8a3d3b15 viff/runtime.py
--- a/viff/runtime.py Tue Apr 21 15:52:17 2009 +0200
+++ b/viff/runtime.py Thu Apr 23 11:21:37 2009 +0200
@@ -321,7 +321,7 @@
else:
deq.append(data)
except struct.error, e:
- print "*** bad data from Player %d: %s" % (self.peer_id, e)
+ self.factory.runtime.abort(self, e)
def sendData(self, program_counter, data_type, data):
"""Send data to the peer.
@@ -566,6 +566,19 @@
sync.addCallback(stop_reactor)
return sync
+ def abort(self, protocol, exc):
+ """Abort the execution due to an exception.
+
+ The *protocol* received bad data which resulted in *exc* being
+ raised when unpacking.
+ """
+ print "*** bad data from Player %d: %s" % (protocol.peer_id, exc)
+ print "*** aborting!"
+ for p in self.protocols.itervalues():
+ p.loseConnection()
+ reactor.stop()
+ print "*** all protocols disconnected"
+
def wait_for(self, *vars):
"""Make the runtime wait for the variables given.
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk