Skip to content

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

Closed
janrygl wants to merge 5 commits into
masterfrom
exit_error_fix
Closed

Fix exit error TypeError("'NoneType' object is not callable",) using catch try block in close method#45
janrygl wants to merge 5 commits into
masterfrom
exit_error_fix

Conversation

@janrygl

@janrygl janrygl commented Apr 26, 2016

Copy link
Copy Markdown

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()

Comment thread sqlitedict.py Outdated
# all data is persisted to disk before returning.
self.conn.commit(blocking=True)
self.conn.close()
except TypeError:

Copy link
Copy Markdown
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

janrygl commented Apr 27, 2016

Copy link
Copy Markdown
Author

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

Comment thread sqlitedict.py
# prevent error log flood in case of multiple SqliteDicts
# closed after connection lost (exceptions are always ignored
# in __del__ method.
pass

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

piskvorky commented May 4, 2016

Copy link
Copy Markdown
Owner

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

@tmylk

tmylk commented May 4, 2016

Copy link
Copy Markdown
Contributor

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

tmylk commented May 15, 2016

Copy link
Copy Markdown
Contributor

Merged in 9cc6dd3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants