Beispiel #1
0
 def initialize(self, _db):
     if __debug__:
         g_logger.debug('call initialize()')
     self._db = _db
     if __debug__:
         g_logger.debug(HttpUtil.get_header_string(self.request))
     pass
Beispiel #2
0
    def pop(self):
        pop_items = {} 
        wait_time = self.__DELAY_TIME 
        current_time = int(time.time())

        pop_count = self.__POP_SIZE 
        while pop_count:
            q_item = self.__queue.head()
            if ECODE.Q_EMPTY == q_item:
                break

            g_logger.debug(q_item)

            q_data, expire_time = q_item

            if current_time >= expire_time:
                assert isinstance(q_data, dict)
                pop_items[q_data['k']] = q_data['v']
                self.__queue.pop()
                self.__set.remove(q_data['k'])
                pass
            else:
                wait_time = expire_time - current_time
                break
            pop_count -= 1
            pass
        return {'data': pop_items, 'wait_time': wait_time}
Beispiel #3
0
    def __handle_async_request(self, response):
        if response is None:
            return None
        #g_logger.debug('STACK_CONTEXT\tself.name=%s' % self.name)
        g_logger.debug('RESPONSE_ERROR\t%s' % response.error)
        g_logger.debug('RESPONSE\t%s' % response)

        return response.body
Beispiel #4
0
    def get(self):
        if __debug__:
            g_logger.debug(self.request.body)

        result = {'code': ECODE.SUCCESS, 'msg': EMSG.SUCCESS}
        result['data'] = {}

        try:
            result['data'] = self.application.stat_info
        except Exception, e:
            g_logger.error(e, exc_info=True if __debug__ else False)
            result['code'] = ECODE.DEFAULT
            result['msg']  = EMSG.DEFAULT
Beispiel #5
0
    def get(self):
        try:
            # 只检查参数,不作业务逻辑处理
            self.name = self._check_argument('name', expect_types=(str, unicode))

            self.api_response({'e_code': ECODE.SUCCESS, 'e_msg': u'Hello, %s!' %
                    self.name})

            if __debug__:
                g_logger.debug(self.db)
                g_logger.debug(self._db)

            self.async_fetch()

        except HTTPError, e:
            g_logger.error(e, exc_info=True)
            return self.api_response({'e_code':ECODE.HTTP, 'e_msg': '%s' % e})
Beispiel #6
0
 def __handle_async_request(self, response):
     g_logger.debug('CURL_ERRNO\t%d', response.error.errno)
     g_logger.debug('STACK_CONTEXT\tself.name=%s',  self.name)
     g_logger.debug('RESPONSE_ERROR\t%s',  response.error)
     g_logger.debug('RESPONSE\t%s',  response)
Beispiel #7
0
 def __handle_async_request(self, response):
     g_logger.debug('CURL_ERRNO\t%d', response.error.errno)
     g_logger.debug('STACK_CONTEXT\tself.name=%s',  self.name)
     g_logger.debug('RESPONSE_ERROR\t%s',  response.error)
     g_logger.debug('RESPONSE\t%s',  response)
Beispiel #8
0
 def initialize(self, version):
     self.version = version
     if __debug__:
         g_logger.debug(HttpUtil.get_header_string(self.request))
Beispiel #9
0
 def db(self):
     if __debug__:
         g_logger.debug('call property::db')
     return self.application.db
Beispiel #10
0
 def initialize(self, version):
     self.version = version
     if __debug__:
         g_logger.debug(HttpUtil.get_header_string(self.request))
Beispiel #11
0
 def db(self):
     if __debug__:
         g_logger.debug('call property::db')
     return self.application.db
Beispiel #12
0
 def initialize(self):
     if __debug__:
         g_logger.debug('call initialize()')
     self.set_header('Server', BaseHandler.HTTP_SERVER_NAME)
     g_logger.info(HttpUtil.get_header_string(self.request))
     pass