summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-03-04 20:23:38 +0000
committerRafael H. Schloming <rhs@apache.org>2008-03-04 20:23:38 +0000
commit47e9a55ae0e729ba7dc10c2800cfb14dc721675f (patch)
tree84c8db5e2ed2dbf35a4ea53b458c2ae1dcd4499f /qpid/python
parentc19ba3eb15620becdbc157005dcc5a465b3ac064 (diff)
downloadqpid-python-47e9a55ae0e729ba7dc10c2800cfb14dc721675f.tar.gz
check the mtime of the cached spec against the code that generates it
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@633623 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/spec010.py7
-rw-r--r--qpid/python/qpid/util.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/qpid/python/qpid/spec010.py b/qpid/python/qpid/spec010.py
index 2d8bd6050d..e6b7946e17 100644
--- a/qpid/python/qpid/spec010.py
+++ b/qpid/python/qpid/spec010.py
@@ -17,8 +17,9 @@
# under the License.
#
-import datatypes
+import os, cPickle, datatypes
from codec010 import StringCodec
+from util import mtime
class Node:
@@ -598,11 +599,9 @@ class Loader:
def do_exception(self, e):
return Exception(id(e["@name"]), id(e["@error-code"]), self.children(e))
-import os, cPickle
-
def load(xml):
fname = xml + ".pcl"
- if os.path.exists(fname):
+ if os.path.exists(fname) and mtime(fname) > mtime(__file__):
file = open(fname, "r")
s = cPickle.load(file)
file.close()
diff --git a/qpid/python/qpid/util.py b/qpid/python/qpid/util.py
index c88cc0c9d6..e41dfc75fb 100644
--- a/qpid/python/qpid/util.py
+++ b/qpid/python/qpid/util.py
@@ -17,7 +17,7 @@
# under the License.
#
-import socket
+import os, socket
def connect(host, port):
sock = socket.socket()
@@ -37,3 +37,6 @@ def listen(host, port, predicate = lambda: True, bound = lambda: None):
while predicate():
s, a = sock.accept()
yield s
+
+def mtime(filename):
+ return os.stat(filename).st_mtime