OL: how to fix a common problem with the waitinglists 

For the OL admins: the following solution is implemented with the Upload loan info button, on the Borrow – Administration page.

The lending system is managed through Internet Archive.
When there is a connection problem between IA and OL during a loan update request (returning or borrowing) it is possible that the waitinglist stalls in an undetermined status.

To fix this situation we are using the script:
/opt/openlibrary/openlibrary/scripts/update-loans.py

The script accept three commands:

    if cmd == "update-loans":
        borrow.update_all_loan_status()
    elif cmd == "update-waitinglists":
        waitinglist.prune_expired_waitingloans()
        waitinglist.update_all_waitinglists()
    elif cmd == "update-waitinglist":
        waitinglist.update_waitinglist(sys.argv[2])
    else:
        usage()

To update and fix a waitinglist we use the update-waitinglist command:

python scripts/openlibrary-server openlibrary.yml runscript scripts/update-loans.py update-waitinglist <InternteArchiveItemId>

Notes:
:: If the script does not run correctly and you receive this error message:
“Required security token not privided or didn’t match.”
it means you don’t have the ia_ol_shared_key in yours openlibrary.yml

:: Do not run the script as root