Beispiel #1
0
def get_load_time():
    """Measure website load time"""
    with database.execution_context() as ctx:
        all_blog = Blog.select()
        for blog in all_blog:
            try:
                speed_seconds = requests.get(
                    blog.url, timeout=5).elapsed.total_seconds()
                blog.network = speed_seconds
                blog.save()
            except Exception:
                logger.error('Timeout: name|%s|url|%s' % (blog.name, blog.url))