Skip to content

Instantly share code, notes, and snippets.

@erikbern
Created August 22, 2013 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikbern/6312391 to your computer and use it in GitHub Desktop.
Save erikbern/6312391 to your computer and use it in GitHub Desktop.
class BsddbTarget(luigi.LocalTarget):
def open(self, mode):
return bsddb.hashopen(self.path, mode) # TODO: make this atomic!!
class TCTarget(luigi.LocalTarget):
open_tcs = {}
def open(self, mode):
if mode == 'r':
if self.path not in TCTarget.open_tcs:
hdb = pytc.HDB()
hdb.open(self.path, pytc.HDBOREADER)
TCTarget.open_tcs[self.path] = hdb
else:
hdb = TCTarget.open_tcs[self.path]
elif mode == 'w':
hdb = pytc.HDB()
hdb.open(self.path, pytc.HDBOWRITER | pytc.HDBOCREAT)
return hdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment