def listen_fds(unset_environment=True):
 fds = int(os.environ.get('LISTEN_FDS', 0))
 listen_pid = int(os.environ.get('LISTEN_PID', 0))
 if (listen_pid != os.getpid()):
  return 0
 if unset_environment:
  os.environ.pop('LISTEN_PID', None)
  os.environ.pop('LISTEN_FDS', None)
 return fds

def listen_fds ( unset_environment = True ) : fds = int ( os . environ . get ( 'LISTEN_FDS' , 0 ) ) listen_pid = int ( os . environ . get ( 'LISTEN_PID' , 0 ) ) if ( listen_pid != os . getpid ( ) ) : return 0 if unset_environment : os . environ . pop ( 'LISTEN_PID' , None ) os . environ . pop ( 'LISTEN_FDS' , None ) return fds
get the number of sockets inherited from systemd socket activation .