code: def append_line(filename, **line):
      
      global lock
  
      data = json.dumps(line, separators=(',', ':')) + '\n'
      with lock:
          with file(filename, 'a') as fp:
              fp.seek(0, SEEK_END)
              fp.write(data)
docs: Safely (i.e. with locking) append a line to
      the given file, serialized as JSON.