You should only get a portalocker.LockException if the no blocking option is set on the lock attempt which it is not the case in the original web2py code.
However, the exception handler inside portalocker.lock will re-raise any exception if it is not IOError for Errno 11 It would be very helpful if you posted the stack trace that shows the exception type and details.