Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Address performance bottlenecks #174

wants to merge 11 commits into from

Conversation

KingAkeem
Copy link
Member

@KingAkeem KingAkeem commented Oct 13, 2019

Fixes #173

Changes Proposed

  • Add new submodule that provides Golang plugin for TorBot, this should provide significant speed improvement and stability.
  • Moves TorBot from requests to aiohttp to introduce asynchronous networking.
  • Add logging

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):
Copy link

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')
Copy link

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)
Copy link

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:
Copy link

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):
Copy link

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()
Copy link

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
Copy link

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
Copy link

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:
Copy link

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')
Copy link

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)

@@ -0,0 +1,27 @@
from ctypes import *
Copy link
Member Author

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:
Copy link

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')
Copy link

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):
Copy link

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):
Copy link

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):
Copy link

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):
Copy link

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

@KingAkeem
Copy link
Member Author

Dropped effort

@KingAkeem KingAkeem closed this Mar 12, 2020
@KingAkeem KingAkeem deleted the mv_to_async branch July 9, 2021 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix multi-threading issue
1 participant