def download(self): global g_mutex while True: print 'b here' providerid = None g_mutex.acquire() print 'b there' for pid in self.dict_provider: #Log.info("for %s,%s" %( pid, self.dict_provider[pid])) if self.dict_provider[pid]==0: #g_mutex.acquire() self.dict_provider[pid] = 1 providerid = pid break #g_mutex.release() g_mutex.release() print 'b done' if providerid is None: #time.sleep(10) continue Log.info("download for providerid: %s" % providerid) g_mutex.acquire() self.dict_provider[providerid]=2 #del self.dict_provider[providerid] g_mutex.release()
def download(self, providerid): # providerid = ''.join(pids) Log.info("download for providerid: %s" % providerid) global g_mutex g_mutex.acquire() self.dict_provider[providerid] = 2 # del self.dict_provider[providerid] g_mutex.release()
def test_func5(): b = 0 try: b= test_func2() except Exception as ex: Log.error("test_func2 error", None, ex) print '='*20 s = test_trace() print s print '='*20 raise print b
def test_func3(): b = 0 try: b= test_func2() except Exception as ex: Log.error("test_func2 error", None, ex) print '='*20 s = StringIO.StringIO() traceback.print_exc(file = s) print s.getvalue() print '='*20 raise print b
def email_error(ex, msg='', level=3, tolog=True): if tolog: Log.error(msg, None, ex) ex_msg = exception2unicode(ex) if msg: msg = u"%s\n%s" % (msg, ex_msg) else: msg = ex_msg tb_msg = traceback_message() message = """ %s\n\n %s\n %s\n %s\n """ % (msg, '-'*20, tb_msg, '-'*20) email_message(message, level)
def get_providers(self): global g_mutex while True: Log.info("load provider") g_mutex.acquire() for i in range(30): id = random.randint(1, 200) if id in self.dict_provider and self.dict_provider[id] == 1: pass else: self.dict_provider[id] = 0 Log.info("load provider, len: %s" % len(self.dict_provider)) g_mutex.release() Log.info("get provider sleep") time.sleep(1) Log.info("get provider walk up")
def test_func7(): while True: Log.info('it is info')
def test_func1(): ''' test_func1 name ''' Log.debug('it is debug') Log.info('it is info') Log.warn('it is warn') Log.error('it is error') Log.debug('it is debug') Log.info('it is info') Log.warn('it is warn') Log.error('it is error') Log.live("it is live")