Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c165f85a
authored
Aug 15, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: log method_cache errors
parent
d933efca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
circle/common/models.py
+9
-0
No files found.
circle/common/models.py
View file @
c165f85a
...
@@ -221,7 +221,13 @@ def compute_cached(method, instance, memcached_seconds,
...
@@ -221,7 +221,13 @@ def compute_cached(method, instance, memcached_seconds,
if
isinstance
(
method
,
basestring
):
if
isinstance
(
method
,
basestring
):
model
,
id
=
instance
model
,
id
=
instance
instance
=
model
.
objects
.
get
(
id
=
id
)
instance
=
model
.
objects
.
get
(
id
=
id
)
try
:
method
=
getattr
(
instance
,
method
)
.
_original
method
=
getattr
(
instance
,
method
)
.
_original
except
AttributeError
:
logger
.
exception
(
"Couldnt get original method of
%
s.
%
s"
,
unicode
(
instance
),
method
.
__name__
)
raise
# call the actual method
# call the actual method
result
=
method
(
instance
,
*
args
,
**
kwargs
)
result
=
method
(
instance
,
*
args
,
**
kwargs
)
# save to memcache
# save to memcache
...
@@ -292,10 +298,13 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
...
@@ -292,10 +298,13 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
elif
not
cache
.
get
(
"
%
s.cached"
%
key
):
elif
not
cache
.
get
(
"
%
s.cached"
%
key
):
logger
.
debug
(
"caches expiring, compute async"
)
logger
.
debug
(
"caches expiring, compute async"
)
cache
.
set
(
"
%
s.cached"
%
key
,
1
,
memcached_seconds
*
0.5
)
cache
.
set
(
"
%
s.cached"
%
key
,
1
,
memcached_seconds
*
0.5
)
try
:
compute_cached
.
apply_async
(
compute_cached
.
apply_async
(
queue
=
'localhost.man'
,
kwargs
=
kwargs
,
args
=
[
queue
=
'localhost.man'
,
kwargs
=
kwargs
,
args
=
[
method_name
,
(
instance
.
__class__
,
instance
.
id
),
method_name
,
(
instance
.
__class__
,
instance
.
id
),
memcached_seconds
,
key
,
time
()]
+
list
(
args
))
memcached_seconds
,
key
,
time
()]
+
list
(
args
))
except
:
logger
.
exception
(
"Couldnt compute async
%
s"
,
method_name
)
return
result
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment