First, that would be great to use the Graph instead, so I can query it. It works the same when adding/binding attributes? I know the difference in constructing it.
BUT I tried to add the close() and still get the same problem. So where do I add the close call? Immediately after my for... loop, after adding the mapping resource to the worldbase, or before/after the worldbase.commit()? I actually am getting an EOFerror, which to me does indicate that a buffer was not flushed to a file. In [7]: c.events ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (454, 0)) --------------------------------------------------------------------------- KeyError Traceback (most recent call last) /home/kdaily/sandbox/<ipython console> in <module>() /home/dock/shared_libraries/lx64/pkgs/pythonsandbox/2.6.2/lib/ python2.6/site-packages/pygr-0.8.0-py2.6-linux-x86_64.egg/pygr/ metabase.pyc in __get__(self, obj, objtype) 59 result=targetDict[obj_id] # MAP USING THE SPECIFIED MAPPING 60 else: ---> 61 result=targetDict[obj] # NOW PERFORM MAPPING IN THAT RESOURCE... 62 if self.targetAttr is not None: 63 result=getattr(result,self.targetAttr) # GET ATTRIBUTE OF THE result /home/dock/shared_libraries/lx64/pkgs/pythonsandbox/2.6.2/lib/ python2.6/site-packages/pygr-0.8.0-py2.6-linux-x86_64.egg/pygr/ mapping.pyc in __getitem__(self, k) 504 def __getitem__(self,k): 505 kID=getattr(k,self.IDAttr) --> 506 return self.getTarget(self.d[kID]) 507 def getTarget(self,vID): 508 if self.itemAttr is not None: /home/dock/shared_libraries/lx64/pkgs/pythonsandbox/2.6.2/lib/ python2.6/site-packages/pygr-0.8.0-py2.6-linux-x86_64.egg/pygr/ mapping.pyc in __getitem__(self, k) 393 return k 394 def __getitem__(self,k): --> 395 return self.d[self.saveKey(k)] 396 def __setitem__(self,k,v): 397 self.d[self.saveKey(k)]=v /pkg/python/2.6.2/lib/python2.6/shelve.pyc in __getitem__(self, key) 119 value = self.cache[key] 120 except KeyError: --> 121 f = StringIO(self.dict[key]) 122 value = Unpickler(f).load() 123 if self.writeback: /pkg/python/2.6.2/lib/python2.6/bsddb/__init__.pyc in __getitem__ (self, key) 265 def __getitem__(self, key): 266 self._checkOpen() --> 267 return _DeadlockWrap(lambda: self.db[key]) # self.db [key] 268 269 def __setitem__(self, key, value): /pkg/python/2.6.2/lib/python2.6/bsddb/dbutils.pyc in DeadlockWrap (function, *_args, **_kwargs) 66 while True: 67 try: ---> 68 return function(*_args, **_kwargs) 69 except db.DBLockDeadlockError: 70 if _deadlock_VerboseFile: /pkg/python/2.6.2/lib/python2.6/bsddb/__init__.pyc in <lambda>() 265 def __getitem__(self, key): 266 self._checkOpen() --> 267 return _DeadlockWrap(lambda: self.db[key]) # self.db [key] 268 269 def __setitem__(self, key, value): KeyError: 'int:1' On Jun 13, 4:24 pm, Christopher Lee <l...@chem.ucla.edu> wrote: > Hi Kenny, > you need to close() the Mapping when you're done writing data to it. > Its file-based storage uses Python shelve, which I believe may not > write its data to disk until you close() it. Mapping tries to call > close() for you automatically when garbage-collected (i.e. > Mapping.__del__ calls self.close()), but as you have just experienced, > that is unpredictable and unreliable (i.e. there's no sure way to know > exactly when Python will garbage-collect your object after you drop > all references to it). > > Note: I think you should Graph (one-to-many or many-to-many) instead > of Mapping (one-to-one). See the tutorial examples or mapping module > docs, and ask if you have questions... > > -- Chris > > On Jun 13, 2009, at 3:52 PM, Kenny Daily wrote: > > > > > So, I've gotten the mapping to work, but only sometimes? > > > The code is here (http://kmdaily.pastebin.com/m6d4a86c3) that I'm > > running. > > > I'm checking the length of the Mapping when I'm done loading all the > > things to map (its ~9000), adding it to worldbase, and checking the > > length again (still 9000). Then, the code exits, and I try to load it > > on the command line or use it again, and it has a 0 length. I look at > > the file that its writing to, and I can see the data in it (the keys > > and values of the objects from the AnnotationDBs that I added). The > > object loads fine, and it accesses the database backend fine as well > > (watching the db connections shows it connecting). Any suggestions how > > to track the problem? Thanks! > > > Kenny --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-dev@googlegroups.com To unsubscribe from this group, send email to pygr-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pygr-dev?hl=en -~----------~----~----~----~------~----~------~--~---