code: def lock(
      filename: str, fail_when_locked: bool, flags: LockFlags
  ) -> LockResult:
      # Returns a case of True, False or FileNotFound
      # https://thedailywtf.com/articles/what_is_truth_0x3f_
      # But seriously, the exception properties cannot be safely pickled so we
      # only return string representations of the exception properties
      try:
          with portalocker.Lock(
              filename,
              timeout=0.1,
              fail_when_locked=fail_when_locked,
              flags=flags,
          ):
              time.sleep(0.2)
              return LockResult()
  
      except Exception as exception:
          # The exceptions cannot be pickled so we cannot return them through
          # multiprocessing
          return LockResult(
              type(exception),
              str(exception),
              repr(exception),
          )
  
imports: from __future__ import print_function
  from __future__ import with_statement
  import os
  import dataclasses
  import multiprocessing
  import time
  import typing
  import pytest
  import portalocker
  from portalocker import utils
  from portalocker import LockFlags
label_desc: Use image node_id 20 for calling a global function with example usage: lock(filename, fail_when_locked, flags) and returns: LockResult, LockResult