class_docstr: Lock manager with built-in timeout
  
  Args:
      filename: filename
      mode: the open mode, 'a' or 'ab' should be used for writing. When mode
          contains `w` the file will be truncated to 0 bytes.
      timeout: timeout when trying to acquire a lock
      check_interval: check interval while waiting
      fail_when_locked: after the initial lock failed, return an error
          or lock the file. This does not wait for the timeout.
      **file_open_kwargs: The kwargs for the `open(...)` call
  
  fail_when_locked is useful when multiple threads/processes can race
  when creating a file. If set to true than the system will wait till
  the lock was acquired and then return an AlreadyLocked exception.
  
  Note that the file is opened first and locked later. So using 'w' as
  mode will result in truncate _BEFORE_ the lock is checked.
docstr: Try to lock the given filehandle
  
  returns LockException if it fails
docstr_tok: ["Try","to","lock","the","given","filehandle","returns","LockException","if","it","fails"]
code: def _get_lock(self, fh: typing.IO) -> typing.IO:
      """
      Try to lock the given filehandle
  
      returns LockException if it fails"""
      portalocker.lock(fh, self.flags)
      return fh
  
imports: import abc
  import atexit
  import contextlib
  import logging
  import os
  import pathlib
  import random
  import tempfile
  import time
  import typing
  import warnings
  from .None import constants, exceptions, portalocker
label_desc: Use image node_id 5 for calling the Lock obj's underlying member method code with example usage: obj._get_lock(fh) and returns: fh