Skip to content

BUG: Unexpected error getting row in parallel.

Getting a nonexistant row from a db in parallel leads to an UnboundLocalError and not a KeyError as expected. This will fix it.

Consider this:

from ase.parallel import rank
from ase.db import connect

# db test
db = connect('newdb.db')
try:
    db.get(4)
except KeyError:
    print 'KeyError on rank {0}'.format(rank)

when I run this with for example: mpirun -np 2 gpaw-python test.py I get an UnboundLocalError and not a KeyError as expected since the select function in ase.db returns nothing.

This fix may break a lot of stuff or there may be better ways of resolving the issue.

Merge request reports