Ejemplo n.º 1
0
def get_remote_status(sources, timeout=5.0):
    conn = aiohttp.TCPConnector(conn_timeout=timeout, use_dns_cache=True)
    headers = generate_user_agent()
    with aiohttp.ClientSession(connector=conn, headers=headers) as client:
        loop = asyncio.get_event_loop()
        result = loop.run_until_complete(process_sources_for_status(client, sources))
    return result
Ejemplo n.º 2
0
def get_remote_tweets(sources, limit=None, timeout=5.0, use_cache=True):
    conn = aiohttp.TCPConnector(conn_timeout=timeout, use_dns_cache=True)
    headers = generate_user_agent()

    with aiohttp.ClientSession(connector=conn, headers=headers) as client:
        loop = asyncio.get_event_loop()

        def start_loop(client, sources, limit, cache=None):
            return loop.run_until_complete(process_sources_for_file(client, sources, limit, cache))

        if use_cache:
            try:
                with Cache.discover() as cache:
                    tweets = start_loop(client, sources, limit, cache)
            except OSError as e:
                logger.debug(e)
                tweets = start_loop(client, sources, limit)
    #comp490
        else:
            tweets = start_loop(client, sources, limit)
    #comp490
    if tweets is None:
        return backup_get_tweets(client,sources,limit)
    else:
        return tweets
Ejemplo n.º 3
0
def get_remote_status(sources, timeout=5.0):
    conn = aiohttp.TCPConnector(use_dns_cache=True)
    headers = generate_user_agent()
    with aiohttp.ClientSession(connector=conn, headers=headers, conn_timeout=timeout) as client:
        loop = asyncio.get_event_loop()
        result = loop.run_until_complete(process_sources_for_status(client, sources))
    return result
Ejemplo n.º 4
0
def get_remote_tweets(sources, limit=None, timeout=5.0, cache=None):
    conn = aiohttp.TCPConnector(conn_timeout=timeout, use_dns_cache=True)
    headers = generate_user_agent()
    with aiohttp.ClientSession(connector=conn, headers=headers) as client:
        loop = asyncio.get_event_loop()

        def start_loop(client, sources, limit, cache=None):
            return loop.run_until_complete(process_sources_for_file(client, sources, limit, cache))

        tweets = start_loop(client, sources, limit, cache)

    return tweets
Ejemplo n.º 5
0
def get_remote_tweets(sources, limit=None, timeout=5.0, cache=None):
    conn = aiohttp.TCPConnector(use_dns_cache=True)
    headers = generate_user_agent()
    with aiohttp.ClientSession(connector=conn, headers=headers, conn_timeout=timeout) as client:
        loop = asyncio.get_event_loop()

        def start_loop(client, sources, limit, cache=None):
            return loop.run_until_complete(process_sources_for_file(client, sources, limit, cache))

        tweets = start_loop(client, sources, limit, cache)

    return tweets
Ejemplo n.º 6
0
def get_remote_tweets(sources, limit=None, timeout=5.0, use_cache=True):
    conn = aiohttp.TCPConnector(conn_timeout=timeout, use_dns_cache=True)
    headers = generate_user_agent()
    with aiohttp.ClientSession(connector=conn, headers=headers) as client:
        loop = asyncio.get_event_loop()

        def start_loop(client, sources, limit, cache=None):
            return loop.run_until_complete(
                process_sources_for_file(client, sources, limit, cache))

        if use_cache:
            try:
                with Cache.discover() as cache:
                    tweets = start_loop(client, sources, limit, cache)
            except OSError as e:
                logger.debug(e)
                tweets = start_loop(client, sources, limit)
        else:
            tweets = start_loop(client, sources, limit)

    return tweets