diff doc/dbg_interactive.py.sample @ 649:5e5d8152c229

Implemented fd_msg_send_timeout to close #10. Not tested yet.
author Sebastien Decugis <sdecugis@nict.go.jp>
date Wed, 05 Jan 2011 17:13:34 +0900
parents 69d3579f6c6c
children 8c3dc8584dab
line wrap: on
line diff
--- a/doc/dbg_interactive.py.sample	Tue Jan 04 16:21:26 2011 +0900
+++ b/doc/dbg_interactive.py.sample	Wed Jan 05 17:13:34 2011 +0900
@@ -463,7 +463,7 @@
 mydwr = msg(buf)
 mydwr.send()
 
-# Optionaly, a callback can be registered when a message is sent, with an optional object.
+# Optionaly, a callback can be registered when a request is sent, with an optional object.
 # This callback takes the answer message as parameter and should return None or a message. (cf. fd_msg_send)
 def send_callback(msg, obj):
     print "Received answer:"
@@ -475,6 +475,21 @@
 mydwr = msg(buf)
 mydwr.send(send_callback, some_object)
 
+# Again optionaly, a time limit can be specified in this case as follow:
+mydwr.send(send_callback, some_object, 10)
+# In that case, if no answer / error is received after 10 seconds (the value specified), 
+# the callback is called with the request as parameter.
+# Testing for timeout case is done by using msg.is_request()
+def send_callback(msg, obj):
+    if (msg.is_request()):
+        print "Request timed out without answer:"
+    else:
+        print "Received answer:"
+    msg.dump()
+    print "Associated data:"
+    obj
+    return None
+
 
 # Set a result code in an answer message.
 mydwr = msg(buf)
"Welcome to our mercurial repository"