If I do a query like this:
return PcpPostModel.query.filter_by(id=post_id).options(
FromCache("default")
)
and then later I do another query like this:
PcpPostModel.query.options(FromCache("default")).all()
Any models that were returned by the first query are now of type: <class
'dogpile.cache.api.CachedValue'>
So then when the second query runs it will except with:
Traceback (most recent call last):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py",
line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py",
line 72, in _run_code
exec code in run_globals
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cProfile.py",
line 199, in <module>
main()
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cProfile.py",
line 192, in main
runctx(code, globs, None, options.outfile, options.sort)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cProfile.py",
line 49, in runctx
prof = prof.runctx(statement, globals, locals)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cProfile.py",
line 140, in runctx
exec cmd in globals, locals
File "scripts/benchmark_boutpage_queries.py", line 45, in <module>
for p in post.related_bouts(4):
File "stufff/post/pcp_post_model.py", line 130, in related_bouts
posts = post_query.options(
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
line 2104, in all
return list(self)
File "stufff/base/caching_query.py", line 71, in __iter__
return self.get_value(createfunc=createfunc)
File "stufff/base/caching_query.py", line 117, in get_value
expiration_time=expiration_time
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/cache/region.py",
line 588, in get_or_create
async_creator) as value:
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/core/dogpile.py",
line 160, in __enter__
return self._enter()
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/core/dogpile.py",
line 100, in _enter
generated = self._enter_create(createdtime)
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/core/dogpile.py",
line 151, in _enter_create
created = self.creator()
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/cache/region.py",
line 570, in gen_value
self.backend.set(key, value)
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/dogpile/cache/backends/memcached.py",
line 168, in set
**self.set_arguments
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/bmemcached/__init__.py",
line 51, in set
returns.append(server.set(key, value, time))
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/bmemcached/__init__.py",
line 382, in set
return self._set_add_replace('set', key, value, time)
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/bmemcached/__init__.py",
line 358, in _set_add_replace
flags, value = self.serialize(value)
File
"/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/site-packages/bmemcached/__init__.py",
line 273, in serialize
value = dumps(value)
File "/Users/aelaguiz/workspace/stufff/venv/lib/python2.7/copy_reg.py",
line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects
Any idea what I can do about this?
Thanks!
Amir
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.