Changeset 2043 for inundation/caching
- Timestamp:
- Nov 21, 2005, 12:10:07 PM (19 years ago)
- Location:
- inundation/caching
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/caching/caching.py
r2040 r2043 403 403 # ----------------------------------------------------------------------------- 404 404 405 # FIXME - moving tounit test405 #Has mostly been moved to proper unit test 406 406 def test(cachedir=None,verbose=0,compression=None): 407 407 """Test the functionality of caching. … … 1218 1218 R = pickler.loads(Rs) 1219 1219 else: 1220 # FIXME (Ole): This crashes if the file has 0 length or is corrupted 1221 # Let's do a try: - except: 1222 R = pickler.load(file) 1220 try: 1221 R = pickler.load(file) 1222 #except EOFError, e: 1223 except: 1224 #Catch e.g., file with 0 length or corrupted 1225 reason = 5 #(Unreadable file) 1226 return None, reason 1227 1223 1228 except MemoryError: 1224 1229 import sys … … 1257 1262 1258 1263 try: 1259 Ts = pickler.dumps(T, bin)1264 Ts = pickler.dumps(T, bin) 1260 1265 except MemoryError: 1261 1266 msg = '****WARNING (caching.py): Could not pickle data for compression.' … … 1264 1269 else: 1265 1270 #Compressed pickling 1266 TsC = zlib.compress(Ts, comp_level)1271 TsC = zlib.compress(Ts, comp_level) 1267 1272 file.write(TsC) 1268 1273 else: 1269 1274 #Uncompressed pickling 1270 pickler.dump(T,file,bin) 1271 1275 pickler.dump(T, file, bin) 1276 1277 # FIXME: This may not work on Windoze network drives. 1278 # The error msg is IOError: [Errno 22] Invalid argument 1279 # Testing with small files was OK, though. 1280 # I think this is an OS problem. 1281 1282 # Excerpt from http://www.ultraseek.com/support/faqs/4173.html 1283 1284 # The error is caused when there is a problem with server disk access (I/0). This happens at the OS level, and there is no controlling these errors through the Ultraseek application. 1285 # 1286 #Ultraseek contains an embedded Python interpreter. The exception "exceptions.IOError: [Errno 22] Invalid argument" is generated by the Python interpreter. The exception is thrown when a disk access operation fails due to an I/O-related reason. 1287 # 1288 #The following extract is taken from the site http://www.python.org: 1289 # 1290 #--------------------------------------------------------------------------------------------- 1291 #exception IOError 1292 #Raised when an I/O operation (such as a print statement, the built-in open() function or a method of a file object) fails for an I/O-related reason, e.g., ``file not found'' or ``disk full''. 1293 #This class is derived from EnvironmentError. See the discussion above for more information on exception instance attributes. 1294 #--------------------------------------------------------------------------------------------- 1295 # 1296 #The error code(s) that accompany exceptions are described at: 1297 #http://www.python.org/dev/doc/devel//lib/module-errno.html 1298 # 1299 #You can view several postings on this error message by going to http://www.python.org, and typing the below into the search box: 1300 # 1301 #exceptions.IOError invalid argument Errno 22 1302 1303 #try: 1304 # pickler.dump(T,file,bin) 1305 #except IOError, e: 1306 # print e 1307 # msg = 'Could not store to %s, bin=%s' %(file, bin) 1308 # raise msg 1272 1309 1273 1310 -
inundation/caching/test_caching.py
r1831 r2043 213 213 set_option('savestat', 1) 214 214 215 N = 200000 #Should be large on fast computers...215 N = 300000 #Should be large on fast computers... 216 216 a = [1,2] 217 217 b = ('Thou shalt count the number three',4) … … 254 254 255 255 256 # def test_network_cachedir(self): 257 258 # #set_option('cachedir', 'H:\\.python_cache\\') 259 # set_option('cachedir', 'V:\\2\\cit\\.python_cache\\') 260 # set_option('verbose', 1) 261 262 263 # # Make some test input arguments 264 # # 265 # N = 5000 #Make N fairly small here 266 267 # a = [1,2] 268 # b = ('Thou shalt count the number three',4) 269 # c = {'Five is right out': 6, (7,8): 9} 270 # x = 3 271 # y = 'holy hand granate' 272 273 # # Test caching 274 # # 275 276 # comprange = 2 277 278 # for comp in range(comprange): 279 280 # # Evaluate and store 281 # # 282 # T1 = cache(f, (a,b,c,N), {'x':x, 'y':y}, evaluate=1, \ 283 # compression=comp) 284 285 # # Retrieve 286 # # 287 # T2 = cache(f, (a,b,c,N), {'x':x, 'y':y}, compression=comp) 288 289 # # Reference result 290 # # 291 # T3 = f(a,b,c,N,x=x,y=y) # Compute without caching 292 293 294 # assert T1 == T2, 'Cached result does not match computed result' 295 # assert T2 == T3, 'Cached result does not match computed result' 256 296 257 297
Note: See TracChangeset
for help on using the changeset viewer.