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

This commit combines a few simple changes. #32

Merged
merged 1 commit into from Mar 26, 2015
Merged

This commit combines a few simple changes. #32

merged 1 commit into from Mar 26, 2015

Conversation

adrianreber
Copy link
Member

  • Initialize the stats dict correctly.
  • Store the time of the last crawl also if the crawl fails.
  • Commit the database changes also if an error occured.

@adrianreber
Copy link
Member Author

This PR includes some simple one-line changes packed together.

logger.removeHandler(fh)
fh.close()
session.commit()
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we want to commit even if an error occurred? Typically, you don't want to do this as it might mean the database records are in some kind of inconsistent or unexpected (exceptional) state.

@adrianreber
Copy link
Member Author

Hmm... The reasoning behind this change was that the changes were only committed after a successful per_host() run. The changes were not committed for the case TimeoutException:.

As the last_time_crawled was not updated correctly in the mark_not_up2date() function I thought I move the commit() and last_time_crawled at the end so that it is done at one central point. Your are right, that it should probably not be committed if something failed.

So I will change this to only commit and write last_time_crawled in try: and TimeoutException:
The close can be left at the place I put it I think. I will update this PR with a new version.

* Initialize the stats dict correctly.
* Store the time of the last crawl also if the crawl fails.
* Commit the database changes also if an error occurred.
@adrianreber
Copy link
Member Author

I have updated my branch and I am not only committing the changes if the crawl was successful or if it timed out. Not if it failed for another reason. I also moved the last_time_crawled just before the session.commit() in both cases session.close() is still after the exception handling.

@ralphbean
Copy link
Contributor

Looks good to me now. 👍!

adrianreber added a commit that referenced this pull request Mar 26, 2015
This commit combines a few simple changes.
@adrianreber adrianreber merged commit 200c86d into fedora-infra:master Mar 26, 2015
@adrianreber adrianreber deleted the simple branch April 27, 2015 12:22
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.

None yet

2 participants