# HG changeset patch # User James Bergstra # Date 1232334016 18000 # Node ID ae954c27fd11178cd842a734e86ca118a4e2f9ad # Parent d2d582bcf7dc23987ac55fda329152c297402378 looping works, eagerload of booked jobs works by str() HACK diff -r d2d582bcf7dc -r ae954c27fd11 pylearn/dbdict/api0.py --- a/pylearn/dbdict/api0.py Sun Jan 18 21:39:28 2009 -0500 +++ b/pylearn/dbdict/api0.py Sun Jan 18 22:00:16 2009 -0500 @@ -406,7 +406,10 @@ h_self._Query = _Query def __iter__(h_self): - return h_self.query.__iter__() + s = h_self.session() + rval = list(h_self.query(s).__iter__()) + s.close() + return rval.__iter__() def insert_kwargs(h_self, session=None, **dct): """ diff -r d2d582bcf7dc -r ae954c27fd11 pylearn/dbdict/sql.py --- a/pylearn/dbdict/sql.py Sun Jan 18 21:39:28 2009 -0500 +++ b/pylearn/dbdict/sql.py Sun Jan 18 22:00:16 2009 -0500 @@ -80,12 +80,12 @@ while (dct is None) and keep_trying: #build a query q = s.query(db._Dict) - #q = q.options(eagerload('_attrs')) #hard-coded in api0 #N.B. # use dedicated column to retrieve jobs, not the dictionary keyval pair # This should be much faster. q = q.filter(db._Dict.status==START) + q = q.options(eagerload('_attrs')) #hard-coded in api0 #try to reserve a dct try: @@ -122,6 +122,8 @@ wait = numpy.random.rand(1)*retry_max_sleep if verbose: print 'another process stole our dct. Waiting %f secs' % wait time.sleep(wait) + if dct: + str(dct) # for loading of attrs in UGLY WAY!!! s.close() return dct