示例#1
0
    async def get(self):
        logger.info('get DemoHandle')

        s = await get_session(self.request)
        if 'skey' in s:
            logger.info('session work ok')
        else:
            s['skey'] = '123'

        return web.Response(text="New hope")
示例#2
0
def load_keywords_for_all(coll, all_cnt):
    logger.debug('load_keywords')

    try:
        k_cn = load_chinese_keyword(all_cnt)
        logger.debug('load chinese keywords: {}'.format(k_cn))
        k_en = load_english_keyword(all_cnt)
        logger.debug('load english keywords: {}'.format(k_en))
        keywords = [] + k_cn + k_en

        coll.update({'types': 'keyword'}, {
            '$set': {
                'types': 'keyword',
                'keywords': keywords,
                'modified_at_gmt': utcnow()
            }
        },
                    upsert=True)
    except Exception as err:
        logger.exception(err)
    else:
        logger.info('keyword done.')
示例#3
0
 def callback(*args, **kw):
     logger.info('tasks heart!')
     gc.collect()
     ioloop.call_later(60, callback, *args, **kw)
示例#4
0
def bind_handle(add_route):
    logger.info('bind_handle')
    add_route('/', DemoHandle)
示例#5
0
def bind_task():
    logger.info("run web_demo")
示例#6
0
async def load_img_labels(aws_conn, im):
    logger.info('detect image...')
    return await ioloop.run_in_executor(thread_executor, _load_img_labels,
                                        aws_conn, im)
示例#7
0
def _load_img_labels(aws_conn, im):
    logger.info('request to deteck image...')
    return aws_conn.detect_labels(Image={'Bytes': im.read()}, MaxLabels=10)
示例#8
0
async def download_img(url):
    logger.info('download image {}'.format(url))
    with aiohttp.ClientSession() as session:
        async with session.get(url) as resp:
            return BytesIO(await resp.read())
示例#9
0
def bind_handle(add_route):
    logger.info('bind_handle aws.rekognition')
    add_route('/detect/', DemoHandle)
示例#10
0
 def callback():
     later = 60 * 60 * 12  # 12 hr
     logger.debug('add new task load_keywords after {}'.format(later))
     logger.info('Run task load_keywords')
     process_executor.submit(load_and_save_post_cnt_and_keywords)
     ioloop.call_later(later, callback)
示例#11
0
 async def get(self):
     logger.info('get WebApps')
     return None
示例#12
0
def bind_handle(add_route):
    logger.info('bind_handle')
    add_route('/', WebApps)
示例#13
0
def bind_task():
    logger.info("run webapps")