# HG changeset patch # User Marcin Kuzminski # Date 2011-10-29 15:44:46 # Node ID cd1c21af123ab0a43cca2cc5f32124c72a64ce67 # Parent 747bc42f1f7de70fd7a4e22aad2f6e585b56065d Fixed problems with unicode cache keys in celery diff --git a/rhodecode/lib/__init__.py b/rhodecode/lib/__init__.py --- a/rhodecode/lib/__init__.py +++ b/rhodecode/lib/__init__.py @@ -195,6 +195,9 @@ def safe_str(unicode_, to_encoding='utf8 :rtype: str :returns: str object """ + + if not isinstance(unicode_, basestring): + return str(unicode_) if isinstance(unicode_, str): return unicode_ diff --git a/rhodecode/lib/celerylib/__init__.py b/rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py +++ b/rhodecode/lib/celerylib/__init__.py @@ -36,7 +36,7 @@ from pylons import config from vcs.utils.lazy import LazyProperty -from rhodecode.lib import str2bool +from rhodecode.lib import str2bool, safe_str from rhodecode.lib.pidlock import DaemonLock, LockHeld from celery.messaging import establish_connection @@ -87,7 +87,7 @@ def __get_lockkey(func, *fargs, **fkwarg func_name = str(func.__name__) if hasattr(func, '__name__') else str(func) lockkey = 'task_%s.lock' % \ - md5(func_name + '-' + '-'.join(map(str, params))).hexdigest() + md5(func_name + '-' + '-'.join(map(safe_str, params))).hexdigest() return lockkey