2222    from  typing  import  Text         # NOQA 
2323    from  typing  import  Optional     # NOQA 
2424    from  typing  import  List         # NOQA 
25+     from  typing  import  Iterable     # NOQA 
2526    from  six  import  text_type       # NOQA 
2627
2728
@@ -321,8 +322,11 @@ def ps_line_to_process(ps_line, now):
321322
322323
323324def  create_kernel_process (now ):
324-     # Fake a process 0, this one isn't returned by ps. More info about PID 0: 
325-     # https://en.wikipedia.org/wiki/Process_identifier 
325+     # type: (datetime.datetime) -> PxProcess 
326+     """ 
327+     Fake a process 0, this one isn't returned by ps. More info about PID 0: 
328+     https://en.wikipedia.org/wiki/Process_identifier 
329+     """ 
326330    process_builder  =  PxProcessBuilder ()
327331    process_builder .pid  =  0 
328332    process_builder .ppid  =  None 
@@ -368,8 +372,10 @@ def resolve_links(processes, now):
368372
369373
370374def  remove_process_and_descendants (processes , pid ):
375+     # type: (Dict[int, PxProcess], int) -> None 
371376    process  =  processes [pid ]
372-     process .parent .children .remove (process )
377+     if  process .parent  is  not None :
378+         process .parent .children .remove (process )
373379    toexclude  =  [process ]
374380    while  toexclude :
375381        process  =  toexclude .pop ()
@@ -394,11 +400,13 @@ def get_all():
394400
395401
396402def  order_best_last (processes ):
403+     # type: (Iterable[PxProcess]) -> List[PxProcess] 
397404    """Returns process list ordered with the most interesting one last""" 
398405    return  sorted (processes , key = operator .attrgetter ('score' , 'cmdline' ))
399406
400407
401408def  order_best_first (processes ):
409+     # type: (Iterable[PxProcess]) -> List[PxProcess] 
402410    """Returns process list ordered with the most interesting one first""" 
403411    ordered  =  sorted (processes , key = operator .attrgetter ('cmdline' ))
404412    ordered  =  sorted (ordered , key = operator .attrgetter ('score' ), reverse = True )
0 commit comments