-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address performance bottlenecks #174
Conversation
else: | ||
|
||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S') | ||
async def on_response_chunk_received(session, trace_config_ctx, params): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 1 blank line, found 0
tree = LinkTree(node, stop_depth=args.depth) | ||
else: | ||
|
||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (109 > 79 characters)
page = LinkIO.read('https://check.torproject.org/', show_msg=True) | ||
page = BeautifulSoup(page, 'html.parser') | ||
ip_cont = page.find('strong') | ||
link = await LinkIO.read('https://check.torproject.org/', show_msg=True, session=session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (97 > 79 characters)
node = LinkNode(link, session) | ||
title = await node.name | ||
link_status = await node.status | ||
except Exception as err: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'err' is assigned to but never used
show_msg=False, | ||
headers=None, | ||
schemes=None, | ||
session=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
continuation line with same indent as next logical line
|
||
@property | ||
async def status(self): | ||
doc = await self.getDocument() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'doc' is assigned to but never used
self._document = BeautifulSoup(await response.text('ISO-8859-1'), 'html.parser') | ||
if get_response: | ||
return self._document, response | ||
return self._document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is not a multiple of four
response = await self._session.get(self.uri, compress=True) | ||
self._document = BeautifulSoup(await response.text('ISO-8859-1'), 'html.parser') | ||
if get_response: | ||
return self._document, response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is not a multiple of four
if not self._document: | ||
response = await self._session.get(self.uri, compress=True) | ||
self._document = BeautifulSoup(await response.text('ISO-8859-1'), 'html.parser') | ||
if get_response: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is not a multiple of four
async def getDocument(self, get_response=False): | ||
if not self._document: | ||
response = await self._session.get(self.uri, compress=True) | ||
self._document = BeautifulSoup(await response.text('ISO-8859-1'), 'html.parser') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (92 > 79 characters)
modules/display_status.py
Outdated
@@ -0,0 +1,27 @@ | |||
from ctypes import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to move this file back to the submodule.
self._uri = link | ||
|
||
async def getDocument(self, get_response=False): | ||
if not self._document: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is not a multiple of four
|
||
class LinkNode: | ||
"""Represents link node in a link tree.""" | ||
DEFAULT_NAME = 'TITLE NOT FOUND' | ||
DEFAULT_STATUS = lambda uri: color(uri, 'yellow') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not assign a lambda expression, use a def
doc, response = await node.getDocument(True) | ||
return response.headers | ||
|
||
async def get_children(node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
|
||
def get_metadata(node): | ||
async def get_status(node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
link = child.get('src') | ||
if link and LinkNode.valid_link(link): | ||
links.append(link) | ||
return links | ||
|
||
async def get_name(node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
|
||
def get_emails(node): | ||
async def get_emails(node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
Dropped effort |
Fixes #173
Changes Proposed
requests
toaiohttp
to introduce asynchronous networking.