twophase error sqlalchemy

2,665 views
Skip to first unread message

Christian Démolis

unread,
Feb 20, 2013, 6:18:04 AM2/20/13
to sqlalchemy
Hi,

AttributeError: 'NoneType' object has no attribute 'twophase'

243.
244.
245.
246.
247.
248.

249.
250.
251.
252.
                        "Session already has a Connection associated for the "
"given Connection's Engine"
)
else:
conn = bind.contextual_connect()

if self.session.twophase and self._parent is None:

transaction = conn.begin_twophase()
elif self.nested:
transaction = conn.begin_nested()
else:

Anybody understand this error ?

Michael Bayer

unread,
Feb 20, 2013, 10:04:22 AM2/20/13
to sqlal...@googlegroups.com
you'd have to illustrate a working example of the code that causes that.


--
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 sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pau Tallada

unread,
Jun 25, 2013, 5:49:18 AM6/25/13
to sqlal...@googlegroups.com
Hi!

I think I've stepped on the same or similar bug.

I have a software which uses zodb transactions to synchronize operations in two databases. In the end, the two databases are the same (we are using the exact same postgresql connection url for both). The software runs fine if only one instance is launched.

But... if I launch more than one instance at a time, there is a great possibility that I get an Exception like this:

Traceback (most recent call last):
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/brownthrower/dispatcher/static/__init__.py", line 238, in _run_job
    transaction.commit()
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/transaction/_manager.py", line 111, in commit
    return self.get().commit()
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/transaction/_transaction.py", line 280, in commit
    reraise(t, v, tb)
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/transaction/_transaction.py", line 271, in commit
    self._commitResources()
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/transaction/_transaction.py", line 417, in _commitResources
    reraise(t, v, tb)
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/transaction/_transaction.py", line 394, in _commitResources
    rm.tpc_vote(self)
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/zope/sqlalchemy/datamanager.py", line 153, in tpc_vote
    self.tx.prepare()
  File "/nfs/pau/PAUdm/codes/tonello/ENV/packaging_test/lib/python2.6/site-packages/sqlalchemy/orm/session.py", line 313, in prepare
    if self._parent is not None or not self.session.twophase:
AttributeError: 'NoneType' object has no attribute 'twophase'

I'm completely lost on this :(

Any clues?

BTW, sessions are created like this:

    engine = create_engine('postgresql://foo')
    
    session_maker = scoped_session(sessionmaker(
        bind = engine,
        twophase = True,
        extension = ZopeTransactionExtension()
    ))

Thank you very much in advance :)

Pau.

2013/2/20 Michael Bayer <mik...@zzzcomputing.com>



--
----------------------------------
Pau Tallada Crespí
Dep. d'Astrofísica i Cosmologia
Port d'Informació Científica (PIC)
----------------------------------

Michael Bayer

unread,
Jun 25, 2013, 10:00:02 AM6/25/13
to sqlal...@googlegroups.com
looks like a zope.transaction issue to me, or at least one where they'd have to show me how they need to use the Session.  They seem to be calling upon session.transaction.prepare() directly at a time when that session.transaction is no longer associated with the parent session.   You'd need to take it up with the zope.transaction folks first.




Pau Tallada

unread,
Jun 26, 2013, 6:54:54 AM6/26/13
to sqlal...@googlegroups.com
Ok, that was my fault.

I was calling rollback() on a sqla.orm.session, instead of calling transaction.abort()
Although the documentation only forbids calling commit, it does not say anything about rolling back an individual session :(

Thanks!

Pau.

2013/6/25 Michael Bayer <mik...@zzzcomputing.com>

Chris Withers

unread,
Jun 28, 2013, 1:43:43 PM6/28/13
to sqlal...@googlegroups.com, Pau Tallada
I wish zope.transaction or something that replaced it would return a
Session subclass that replaces .commit and .rollback with calls to
transaction.commit and transaction.abort rather than raising an
exception with one and silently doing the wrong thing with the other :-/

Chris

On 26/06/2013 11:54, Pau Tallada wrote:
> Ok, that was my fault.
>
> I was calling rollback() on a sqla.orm.session, instead of calling
> transaction.abort()
> Although the documentation only forbids calling commit, it does not say
> anything about rolling back an individual session :(
>
> Thanks!
>
> Pau.
>
> 2013/6/25 Michael Bayer <mik...@zzzcomputing.com
> <mailto:mik...@zzzcomputing.com>>
>
> looks like a zope.transaction issue to me, or at least one where
> they'd have to show me how they need to use the Session. They seem
> to be calling upon session.transaction.prepare() directly at a time
> when that session.transaction is no longer associated with the
> parent session. You'd need to take it up with the zope.transaction
> folks first.
>
>
>
>
> On Jun 25, 2013, at 5:49 AM, Pau Tallada <tal...@pic.es
>> <mailto:mik...@zzzcomputing.com>>
>>
>> you'd have to illustrate a working example of the code that
>> causes that.
>>
>>
>> On Feb 20, 2013, at 6:18 AM, Christian D�molis
>> <christia...@gmail.com
>>> <mailto:sqlalchemy+...@googlegroups.com>.
>>> To post to this group, send email to
>>> sqlal...@googlegroups.com <mailto:sqlal...@googlegroups.com>.
>>> Visit this group at
>>> http://groups.google.com/group/sqlalchemy?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
>> --
>> 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 sqlalchemy+...@googlegroups.com
>> <mailto:sqlalchemy%2Bunsu...@googlegroups.com>.
>> To post to this group, send email to
>> sqlal...@googlegroups.com <mailto:sqlal...@googlegroups.com>.
>> Visit this group at
>> http://groups.google.com/group/sqlalchemy?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>>
>>
>> --
>> ----------------------------------
>> Pau Tallada Cresp�
>> Dep. d'Astrof�sica i Cosmologia
>> Port d'Informaci� Cient�fica (PIC)
>> Tel: +34 93 586 8233 <tel:%2B34%2093%20586%208233>
>> ----------------------------------
>>
>>
>> --
>> 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 sqlalchemy+...@googlegroups.com
>> <mailto:sqlalchemy+...@googlegroups.com>.
>> To post to this group, send email to sqlal...@googlegroups.com
>> <mailto:sqlal...@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> 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 sqlalchemy+...@googlegroups.com
> <mailto:sqlalchemy%2Bunsu...@googlegroups.com>.
> To post to this group, send email to sqlal...@googlegroups.com
> <mailto:sqlal...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
> --
> ----------------------------------
> Pau Tallada Cresp�
> Dep. d'Astrof�sica i Cosmologia
> Port d'Informaci� Cient�fica (PIC)
> Tel: +34 93 586 8233
> ----------------------------------
>
> --
> 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 sqlalchemy+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
Reply all
Reply to author
Forward
0 new messages