-
Notifications
You must be signed in to change notification settings - Fork 2
Creating a restart function for storage classes to fix broken database connections #196
Conversation
except storage.Error: | ||
logger.exception('Storage failed to restart') | ||
finally: | ||
raise httpexceptions.HTTPServiceUnavailable() |
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.
Just curious if there is anyway to make this section more concise without having to use these nested try / except statements
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.
I don't know a better way to do this.
3ff8f26
to
3389885
Compare
f9d4ff3
to
bf4d85e
Compare
Since were adding a coveralls configuration file I think that it would be best to leave this pull request as two separate commits since the commits address two distinct issues. |
@@ -61,6 +61,7 @@ class PostgresqlStorage(BaseStorage): | |||
def __init__(self, db_connection_string=None): | |||
#initialize db | |||
self.conn = psycopg2.connect(db_connection_string) | |||
self.db_connection_string = db_connection_string |
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.
adding a variable to store the db_connection string needed to restart the database when a connection is broken or lost.
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.
Come to think about it, shouldn't your note be comment in the code?
… database connections
fa6bf17
to
333bcf1
Compare
Changes Unknown when pulling 333bcf1 on database_restart into * on master*. |
333bcf1
to
b06530a
Compare
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain if tests don't hit defensive assertion code: |
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.
I don't think this comment is relevant
Changes Unknown when pulling b06530a on database_restart into * on master*. |
b06530a
to
8bca86d
Compare
Changes Unknown when pulling 8bca86d on database_restart into * on master*. |
Why is the Otherwise, I think this is ready to roll. |
5715949
to
1b2446a
Compare
Changes Unknown when pulling 1b2446a on database_restart into * on master*. |
I adjusted the |
Creating a restart function for storage classes to fix broken database connections
Oh but may be it's good to include the tests in the coverage. Just in case tests got skipped because we have some indentation error, or because of copy and paste error (See openstax/cnx-archive@09fdd6a). |
@karenc That's a good point, but it also artificially inflates the coverage (i.e. 92% vs 96%). I'll pull it out in a followup pull request. Unfortunately, you comment came in just after I pushed the button. |
@pumazi the |
I believe it would be better to make the For now, I'd say it belongs in the |
ok! I made an issue #200 suggesting that we make a context manager in the Base storage class. I'll also make a pull request to refactor the |
I may have misunderstood this somewhat. But we'll see what happens. |
Fix #47