From 8e6333226e7015483f6bddac697abb8534d088a6 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Thu, 29 May 2014 00:52:44 +0900 Subject: [PATCH] unknow bug in Mac OS: Stream process die after db is truncated --- rainbowstream/db.py | 15 +++------------ rainbowstream/rainbow.py | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/rainbowstream/db.py b/rainbowstream/db.py index ce299c9..cac9a73 100644 --- a/rainbowstream/db.py +++ b/rainbowstream/db.py @@ -30,7 +30,7 @@ class RainbowDB(): """ Session = sessionmaker(bind=self.engine) session = Session() - res = session.query(Map).filter("rainbow_id =:rid").params(rid=rid).all() + res = session.query(Map).filter_by(rainbow_id=rid).all() return res def tweet_query(self, tid): @@ -39,14 +39,5 @@ class RainbowDB(): """ Session = sessionmaker(bind=self.engine) session = Session() - res = session.query(Map).filter("tweet_id =:tid").params(tid=tid).all() - return res - - def truncate(self): - """ - Truncate table - """ - Session = sessionmaker(bind=self.engine) - session = Session() - session.query(Map).delete() - session.commit() + res = session.query(Map).filter_by(tweet_id=tid).all() + return res \ No newline at end of file diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 3a558e0..53c002f 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -322,7 +322,7 @@ def quit(): """ Exit all """ - db.truncate() + os.system('rm -rf rainbow.db') os.kill(g['stream_pid'], signal.SIGKILL) sys.exit() -- 2.25.1