Problem starting a distributed transaction

15 views
Skip to first unread message

Carlos Correia

unread,
Jul 3, 2020, 9:40:37 AM7/3/20
to web2py-users
Hi,

I have this piece of code in a controller to test a distributed transaction but it fails with: 
"ValueError: need more than 0 values to unpack".

def index():
    response.flash = T("Hello World")
    db0 = DAL( 'postgres://belmiro:naosei@localhost/ennos__blm_0139' )
    db1 = DAL( 'postgres://belmiro:naosei@localhost/ennos__blm_0143' )
    DAL.distributed_transaction_begin( db0, db1 )
    db0.auth_event.insert( description='test tx 0' )
    db1.auth_event.insert( description='test tx 1' )
    DAL.distributed_transaction_commit( db0, db1 )
    return dict(message=T('Welcome to web2py!'))

Stack trace:

  File ".../web2py/applications/welcome/controllers/default.py", line 12, in index
    DAL.distributed_transaction_begin( db0, db1 )
  File ".../web2py/gluon/packages/dal/pydal/base.py", line 341, in distributed_transaction_begin
    keys = ['%s.%i' % (thread_key, i) for (i, db) in instances]


What I am doing wrong?


Thanks,

Carlos Correia
=========================
MEMÓRIA PERSISTENTE
GSM:  917 157 146 (Signal, WhatsApp)
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt
GnuPG: wwwkeys.eu.pgp.net

Carlos Correia

unread,
Jul 4, 2020, 9:10:57 AM7/4/20
to web...@googlegroups.com
Às 14:40 de 03/07/20, Carlos Correia escreveu:
Hi,

I have this piece of code in a controller to test a distributed transaction but it fails with: 
"ValueError: need more than 0 values to unpack".

def index():
    response.flash = T("Hello World")
    db0 = DAL( 'postgres://belmiro:naosei@localhost/ennos__blm_0139' )
    db1 = DAL( 'postgres://belmiro:naosei@localhost/ennos__blm_0143' )
    DAL.distributed_transaction_begin( db0, db1 )
    db0.auth_event.insert( description='test tx 0' )
    db1.auth_event.insert( description='test tx 1' )
    DAL.distributed_transaction_commit( db0, db1 )
    return dict(message=T('Welcome to web2py!'))

Stack trace:

  File ".../web2py/applications/welcome/controllers/default.py", line 12, in index
    DAL.distributed_transaction_begin( db0, db1 )
  File ".../web2py/gluon/packages/dal/pydal/base.py", line 341, in distributed_transaction_begin
    keys = ['%s.%i' % (thread_key, i) for (i, db) in instances]


What I am doing wrong?


Hi,

It has a bug in gluon/packages/dal/pydal/base.py at lines 341 and 342, which should be switched.

341         keys = ['%s.%i' % (thread_key, i) for (i, db) in instances]
342         instances = enumerate(instances)

should be:

341         instances = enumerate(instances)
342         keys = ['%s.%i' % (thread_key, i) for (i, db) in instances]

I switched the lines, tested, and it worked as expected.



Best regards,

Reply all
Reply to author
Forward
0 new messages