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

... #9

Merged
merged 29 commits into from
Dec 13, 2012
Merged

... #9

merged 29 commits into from
Dec 13, 2012

Conversation

lud4ik
Copy link
Contributor

@lud4ik lud4ik commented Dec 7, 2012

No description provided.

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можешь написать это без eval?

asvetlov added a commit that referenced this pull request Dec 13, 2012
@asvetlov asvetlov merged commit 33d5b3e into learnpython:master Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants