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

Fix exit error TypeError("'NoneType' object is not callable",) using catch try block in close method #45

Closed
wants to merge 5 commits into from

Conversation

janrygl
Copy link

@janrygl janrygl commented Apr 26, 2016

Fixes #44

@piskvorky
Added try catch block to close function to prevent error log message in __del__ method when sqlitedict is not closed correctly. Error was raised by conn.close() and conn.commit()

# all data is persisted to disk before returning.
self.conn.commit(blocking=True)
self.conn.close()
except TypeError:
Copy link
Owner

Choose a reason for hiding this comment

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

Is TypeError enough? May be better to catch all Exceptions?

@janrygl
Copy link
Author

janrygl commented Apr 27, 2016

@tmylk @piskvorky I rebased commits to return to original close method and added only try catch to __del__ method.

# prevent error log flood in case of multiple SqliteDicts
# closed after connection lost (exceptions are always ignored
# in __del__ method.
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we print the exception to sys.stderr?
As in del docs

exceptions that occur during their execution are ignored, and a warning is printed to sys.stderr instead.

Copy link
Owner

Choose a reason for hiding this comment

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

No, getting rid of the flood of logged exceptions is the entire reason for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we at least print a warning instead of an exception?

@piskvorky
Copy link
Owner

piskvorky commented May 4, 2016

@janrygl @tmylk this PR seems to contain unrelated changes (read-only sqlite?) -- what's going on there?

@tmylk
Copy link
Contributor

tmylk commented May 4, 2016

The read-only commits have already been merged. I was planning to cherry-pick just @janrygl's changes once we converge here.

tmylk added a commit that referenced this pull request May 15, 2016
@tmylk
Copy link
Contributor

tmylk commented May 15, 2016

Merged in 9cc6dd3

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.

Fix exit errors: TypeError("'NoneType' object is not callable",)
4 participants