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

Add flag for sigint signal handler #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions proxybroker/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Broker:

def __init__(self, queue=None, timeout=8, max_conn=200, max_tries=3,
judges=None, providers=None, verify_ssl=False, loop=None,
**kwargs):
stop__broker_on_sigint=True, **kwargs):
self._loop = loop or asyncio.get_event_loop()
self._proxies = queue or asyncio.Queue(loop=self._loop)
self._resolver = Resolver(loop=self._loop)
Expand Down Expand Up @@ -88,13 +88,13 @@ def __init__(self, queue=None, timeout=8, max_conn=200, max_tries=3,
self._judges = judges
self._providers = [p if isinstance(p, Provider) else Provider(p)
for p in (providers or PROVIDERS)]

try:
self._loop.add_signal_handler(signal.SIGINT, self.stop)
# add_signal_handler() is not implemented on Win
# https://docs.python.org/3.5/library/asyncio-eventloops.html#windows
except NotImplementedError:
pass
if stop__broker_on_sigint:
try:
self._loop.add_signal_handler(signal.SIGINT, self.stop)
# add_signal_handler() is not implemented on Win
# https://docs.python.org/3.5/library/asyncio-eventloops.html#windows
except NotImplementedError:
pass

async def grab(self, *, countries=None, limit=0):
"""Gather proxies from the providers without checking.
Expand Down