-
Notifications
You must be signed in to change notification settings - Fork 11
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
... #9
... #9
Conversation
@@ -29,64 +31,61 @@ def __init__(self, host, port): | |||
def run_client(cls, host, port): | |||
client = cls(host, port) | |||
try: | |||
handler = signal.signal(signal.SIGINT, shutdown_handler) |
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.
Мелочь, но эту строчку нужно вынести за try.
Потому что есть signa.signal вывалится с ошибкой то в finally возвращать старый обработчик не нужно (он и так стоит), да и не из чего (handler еще не присвоет и просто не существует).
Аналогично, например, нужно делать с блокировками без with:
l = RLock()
# ....
l.acquire()
try:
do_something()
finally:
l.release()
cmd_input = getattr(cmd, command[0].upper()) | ||
if cmd_input == cmd.PINGD: | ||
kwargs['data'] = command[1] | ||
packet = eval('{}(**kwargs).pack()'.format(command[0])) |
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.
Можешь написать это без eval?
No description provided.