import filelock
import pickle


def pickle_read(filename):
    """Read pickle file contents with a lock."""
    lock = filelock.FileLock(filename+'.lck',timeout=20)
    pickle_data = None
    with lock:
        pickle_data = pickle.load(open(filename, 'rb'))
    return pickle_data