-
Notifications
You must be signed in to change notification settings - Fork 2
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
a simple loop #3
Conversation
# Conflicts: # GracefulKiller/GracefulKiller.py # GracefulKiller/__init__.py # GracefulKiller/test_GracefulKiller.py # README.md
@cuihairu, could you please provide some description and use cases for your changes. |
@MaxMaxoff my English is not too good, I wish I could express it clearly. |
GracefulKiller/GracefulKiller.py
Outdated
cls.instance = super(Loop, cls).__new__(cls) | ||
return cls.instance | ||
|
||
def __init__(self, killer, delay): |
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.
could you please update killer and delay with default values, like killer=None, delay=1 or etc.
GracefulKiller/GracefulKiller.py
Outdated
return cls.instance | ||
|
||
def __init__(self, killer, delay): | ||
assert killer is not None and isinstance(killer, GracefulKiller) |
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.
why it can't be just like this:
assert killer and isinstance(killer, GracefulKiller)
?
GracefulKiller/GracefulKiller.py
Outdated
self.delay = delay | ||
|
||
def loop(self): | ||
while True: |
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.
Looks more simple, what do you think?
while not self.killer.kill_now: time.sleep(self.delay)
@cuihairu, now I understand what you're offer in this PR. |
GracefulKiller/GracefulKiller.py
Outdated
|
||
def __init__(self, killer, delay): | ||
assert killer is not None and isinstance(killer, GracefulKiller) | ||
if delay is 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.
you can pass it if you will define default values for delay
GracefulKiller objects create multiple, and only one of them takes effect.