Created
August 22, 2013 20:31
-
-
Save erikbern/6312391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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