@@ -75,6 +75,9 @@ def disconnect(self):
7575 self .cursor .close ()
7676 self .connection .close ()
7777
78+ def commit (self ):
79+ self .cursor .commit ()
80+
7881 def execute (self , statement , arguments = None ):
7982 if arguments :
8083 self .cursor .execute (statement , arguments )
@@ -186,6 +189,10 @@ def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None):
186189 output = conf .database_cursor .execute ("SELECT id, value FROM data WHERE taskid = ? AND status = ? AND content_type = ? LIMIT 0,1" ,
187190 (self .taskid , status , content_type ))
188191
192+ # Delete partial output from IPC database if we have got a complete output
193+ if status == CONTENT_STATUS .COMPLETE and len (output ) > 0 :
194+ conf .database_cursor .execute ("DELETE FROM data WHERE id=?" , (output [0 ][0 ],))
195+
189196 if status == CONTENT_STATUS .IN_PROGRESS :
190197 if len (output ) == 0 :
191198 conf .database_cursor .execute ("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)" ,
@@ -195,10 +202,6 @@ def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None):
195202 conf .database_cursor .execute ("UPDATE data SET value = ? WHERE id = ?" ,
196203 (jsonize (new_value ), output [0 ][0 ]))
197204 else :
198- if len (output ) > 0 :
199- conf .database_cursor .execute ("DELETE FROM data WHERE taskid = ? AND status = %s AND content_type = ?" % CONTENT_STATUS .IN_PROGRESS ,
200- (self .taskid , content_type ))
201-
202205 conf .database_cursor .execute ("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)" ,
203206 (self .taskid , status , content_type , jsonize (value )))
204207 else :
0 commit comments