[svn] commit: r3004 - in /branches/trac349/src/lib/python/isc/config: ccsession.py tests/unittest_fakesession.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 23 06:29:51 UTC 2010
Author: vorner
Date: Thu Sep 23 06:29:51 2010
New Revision: 3004
Log:
Allow ccsession to have a block command check
Modified:
branches/trac349/src/lib/python/isc/config/ccsession.py
branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py
Modified: branches/trac349/src/lib/python/isc/config/ccsession.py
==============================================================================
--- branches/trac349/src/lib/python/isc/config/ccsession.py (original)
+++ branches/trac349/src/lib/python/isc/config/ccsession.py Thu Sep 23 06:29:51 2010
@@ -1,4 +1,5 @@
# Copyright (C) 2009 Internet Systems Consortium.
+# Copyright (C) 2010 CZ NIC
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -169,20 +170,25 @@
time-critical, it is strongly recommended to only use
check_command(), and not look at the socket at all."""
return self._session._socket
-
+
def close(self):
"""Close the session to the command channel"""
self._session.close()
- def check_command(self):
+ def check_command(self, nonblock = True):
"""Check whether there is a command or configuration update
on the channel. Call the corresponding callback function if
- there is. This function does a non-blocking read on the
- cc session, and returns nothing. It will respond to any
- command by either an error or the answer message returned
- by the callback, unless the latter is None."""
- msg, env = self._session.group_recvmsg(True)
-
+ there is. This function does a read on the cc session, and
+ returns nothing. It will respond to any command by either
+ an error or the answer message returned by the callback,
+ unless the latter is None."""
+ timeout_orig = self._session.get_timeout()
+ self._session.set_timeout(0)
+ try:
+ msg, env = self._session.group_recvmsg(nonblock)
+ finally:
+ self._session.set_timeout(timeout_orig)
+
# should we default to an answer? success-by-default? unhandled error?
if msg is not None and not 'result' in msg:
answer = None
Modified: branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py
==============================================================================
--- branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py (original)
+++ branches/trac349/src/lib/python/isc/config/tests/unittest_fakesession.py Thu Sep 23 06:29:51 2010
@@ -88,3 +88,6 @@
def set_timeout(self, timeout):
self._timeout = timeout
+
+ def get_timeout(self):
+ return self._timeout
More information about the bind10-changes
mailing list