Open ashuezy opened 3 years ago
sql_operation(0, oneId, twoId, threeId, fc)
def sql_operation(w, oneId, twoId, threeId, fc): global code_folder fc2=0 try: if w==0: try: mydict = SqliteDict(code_folder+'core.sqlite', autocommit=True) uid = str(oneId)+"_"+str(twoId)+"_"+str(threeId) mydict[uid] = fc except Exception as e0: logger.error(e0) finally: mydict.close() elif w==1: try: logger.info('Acquiring Lock by fetchRow') lock.acquire(timeout=5) logger.info('Lock Taken by fetchRow') mydict = SqliteDict(code_folder+'core.sqlite', autocommit=True) uid = str(oneId)+"_"+str(twoId)+"_"+str(threeId) fc2 = mydict[uid] except Exception as e1: logger.error(e1) finally: mydict.close() logger.info('Releasing Lock by fetchRow') lock.release() logger.info('Lock Released by fetchRow') except Exception as e: logger.error(e) return fc2
sql_operation(0, oneId, twoId, threeId, fc)