def file_descriptors_used(pid):
 try:
  pid = int(pid)
  if (pid < 0):
   raise IOError(("Process pids can't be negative: %s" % pid))
 except (ValueError, TypeError):
  raise IOError(('Process pid was non-numeric: %s' % pid))
 try:
  return len(os.listdir(('/proc/%i/fd' % pid)))
 except Exception as exc:
  raise IOError(('Unable to check number of file descriptors used: %s' % exc))

def file_descriptors_used ( pid ) : try : pid = int ( pid ) if ( pid < 0 ) : raise IOError ( ( "Process pids can't be negative: %s" % pid ) ) except ( ValueError , TypeError ) : raise IOError ( ( 'Process pid was non-numeric: %s' % pid ) ) try : return len ( os . listdir ( ( '/proc/%i/fd' % pid ) ) ) except Exception as exc : raise IOError ( ( 'Unable to check number of file descriptors used: %s' % exc ) )
provides the number of file descriptors currently being used by a process .