[Kimchi-devel] [PATCH 1/5] Fix 'disk full' issue: Change objectstore exception handling

Aline Manera alinefm at linux.vnet.ibm.com
Tue Mar 25 18:43:02 UTC 2014


On 03/24/2014 05:53 PM, Rodrigo Trujillo wrote:
> This patch changes __exit__ function of objectstore in order to log the
> error information. It also changes the return to make python raise the
> exception again, which will be caught by the functions that are using
> the objectstore.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/kimchi/objectstore.py | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/src/kimchi/objectstore.py b/src/kimchi/objectstore.py
> index d960ca9..e9baad5 100644
> --- a/src/kimchi/objectstore.py
> +++ b/src/kimchi/objectstore.py
> @@ -19,6 +19,7 @@
>   import json
>   import sqlite3
>   import threading
> +import traceback
>
>
>   try:
> @@ -29,6 +30,7 @@ except ImportError:
>
>   from kimchi import config
>   from kimchi.exception import NotFoundError
> +from kimchi.utils import kimchi_log
>
>
>   class ObjectStoreSession(object):
> @@ -116,3 +118,9 @@ class ObjectStore(object):
>
>       def __exit__(self, type, value, tb):
>           self._lock.release()
> +        if type is not None:
> +            if issubclass(type, sqlite3.DatabaseError):
> +                # Logs the error and return False, which makes __exit__ raise
> +                # exception again
> +                kimchi_log.error(traceback.format_exc())
> +                return False

You can avoid multiples indentation levels:

if type is not None and issubclass(type, sqlite3.DatabaseError):
     ...






More information about the Kimchi-devel mailing list