-
Notifications
You must be signed in to change notification settings - Fork 19
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
Email support #228
Email support #228
Conversation
if cls.connection is None or cls.connection.noop()[0] == 421: | ||
return True | ||
else: | ||
return False |
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.
Either this method, or connection.noop() has a really unfortunate name. It's not clear to me how this if statement can be connecting or reconnecting via side effects from a function called no op :).
Maybe this could be renamed to requires_reconnect() or is_active() with appropriate changes to booleans returned
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.
Ahh, wait, I'm misunderstanding what the comment is attached to :D
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.
.noop()
is part of smtplib.SMTP
and issues a NOOP
command server side. This will report a timeout if the connection has died.
return connection | ||
|
||
@classmethod | ||
def connect(cls): |
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.
Is this synchronous?
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.
Ya, per slack though, I think we defer async for now
message.attach(second) | ||
|
||
cls.connect() | ||
cls.connection.send_message(message) |
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.
Coming from a mobile development background, where connections unexpectedly drop all the freaking time, I think this pattern is slightly wrong, though I doubt we'll ever notice while the server is colocated. If the connect call succeeds, but then the connection immediately drops out, what happens when you call send_message?
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.
fair. happy to wrap and catch?
An object to support sending jinja2 templated emails. This is provides partial support for biocore/microsetta-admin#17