Function to lock a file using memcache, Version 2
logical flaw

If an exception happens, your key could remain locked.

You use

def addToCart(filename, username):
    ableToLock = memcache.add(filename, username)
    if ableToLock:
        # ableToLock can happen if the file is still present
        # or if it was already processed.
        if os.file.ispath(filename):
            # I have a lock and file exists. Think of Cart as a
            # JS Object from where you can pick items to "process".
            return "Added To Cart"
        else:
            # I have a lock but looks like file was processed already.
            # So removing the residual "key" created.
            memcache.delete(filename)
            return "Processed by another user." 
    else:
        ...



def process(source):
    shutil.move(source, destination)
    # filename =&gt; source 
    memcache.delete(filename)


What if shutil.move throws an exception? Or print?

Better would be

if ableToLock:
    try:
        # ableToLock can happen if the file is still present
        # or if it was already processed.
        if os.file.ispath(filename):
            # I have a lock and file exists. Think of Cart as a
            # JS Object from where you can pick items to "process".
            return "Added To Cart"
        else:
            return "Processed by another user." 
    finally:
        memcache.delete(filename)