I'm hitting a weird sqlalchemy session error when running tests via
nose.
The error is:
InvalidRequestError: Object '<Task at 0x104f979d0>' is already
attached to session '4369008080' (this is '4375937168')
This error only shows up when I run all the tests together. When
running 1 or 2 tests everything is fine.
The code in question (called from within the controller) is:
t = Task(num, name, t_type, owner_group, entity, machine, parent,
timeout, payload, creds, run_as)
t.created=datetime.now()
t.lastmodified=t.created
t.createdby=caller.name
t.lastmodifiedby=t.createdby
log.debug("t:%s" % (t,))
_sess.add(t)
_sess.commit()
Fails for the _sess.add(t) line. I'm thoroughly confused how a newly
created object can be part of an existing session. Any help would be
appreciated.
The full stack trace:
======================================================================
ERROR: Test showing run page for a workflow
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/aaditya/src/id/src/id/vaitarna/vaitarna/tests/
functional/test_workflow.py", line 43, in test_showrun
wf=create_workflow_web(self.app,u,g,'wf-run',1,timestamp)
File "/Users/aaditya/src/id/src/id/vaitarna/vaitarna/tests/
__init__.py", line 109, in create_workflow_web
response=app.post(url(controller='workflow',
action='create',name=full_name),extra_environ=dict(REMOTE_USER=str
(user.name),REMOTE_GROUP=str(group.name)))
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebTest-1.1-py2.6.egg/webtest/__init__.py", line 202, in post
content_type=content_type)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebTest-1.1-py2.6.egg/webtest/__init__.py", line 182, in
_gen_request
expect_errors=expect_errors)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebTest-1.1-py2.6.egg/webtest/__init__.py", line 306, in
do_request
res = req.get_response(app, catch_exc_info=True)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebOb-0.9.6.1-py2.6.egg/webob/__init__.py", line 1321, in
get_response
application, catch_exc_info=True)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebOb-0.9.6.1-py2.6.egg/webob/__init__.py", line 1293, in
call_application
app_iter = application(self.environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebTest-1.1-py2.6.egg/webtest/lint.py", line 170, in lint_app
iterator = application(environ, start_response_wrapper)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Paste-1.7.2-py2.6.egg/paste/cascade.py", line 130, in
__call__
return self.apps[-1](environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Paste-1.7.2-py2.6.egg/paste/registry.py", line 350, in
__call__
app_iter = self.application(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/middleware.py", line 201, in
__call__
self.app, environ, catch_exc_info=True)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/util.py", line 94, in
call_wsgi_application
app_iter = application(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebError-0.10.1-py2.6.egg/weberror/evalexception.py", line
235, in __call__
return self.respond(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/WebError-0.10.1-py2.6.egg/weberror/evalexception.py", line
418, in respond
return self.application(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Beaker-1.4.1-py2.6.egg/beaker/middleware.py", line 73, in
__call__
return self.app(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Beaker-1.4.1-py2.6.egg/beaker/middleware.py", line 152, in
__call__
return self.wrap_app(environ, session_start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Routes-1.10.3-py2.6.egg/routes/middleware.py", line 130, in
__call__
response = self.app(environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/wsgiapp.py", line 125, in
__call__
response = self.dispatch(controller, environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/wsgiapp.py", line 324, in
dispatch
return controller(environ, start_response)
File "/Users/aaditya/src/id/src/id/vaitarna/vaitarna/lib/base.py",
line 39, in __call__
return WSGIController.__call__(self, environ, start_response)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py", line 221,
in __call__
response = self._dispatch_call()
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py", line 172,
in _dispatch_call
response = self._inspect_call(func)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py", line 107,
in _inspect_call
result = self._perform_call(func, args)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/Pylons-0.9.7-py2.6.egg/pylons/controllers/core.py", line 60,
in _perform_call
return func(**args)
File "/Users/aaditya/src/id/src/id/vaitarna/vaitarna/controllers/
workflow.py", line 60, in create
wf=create_task(0,name,Task.WORKFLOW, group, user, _sess=Session)
File "/Users/aaditya/src/id/src/id/db/schema.py", line 303, in
create_task
_sess.add(t)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/scoping.py", line
123, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/session.py", line
1091, in add
self._save_or_update_state(state)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/session.py", line
1100, in _save_or_update_state
self._save_or_update_impl(state)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/session.py", line
1265, in _save_or_update_impl
self._save_impl(state)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/session.py", line
1244, in _save_impl
self._attach(state)
File "/Users/aaditya/src/python/virtual/epsilon/lib/python2.6/site-
packages/SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/session.py", line
1293, in _attach
state.session_id, self.hash_key))
InvalidRequestError: Object '<Task at 0x104f979d0>' is already
attached to session '4369008080' (this is '4375937168')
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.