<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cmd_reindex():
 """Uses CREATE INDEX CONCURRENTLY to create a duplicate index, then tries to swap the new index for the original. The index swap is done using a short lock timeout to prevent it from interfering with running queries. Retries until the rename succeeds. """

    db = connect(args.database)
    for idx in args.indexes:
        pg_reindex(db, idx)