@@ -721,11 +721,15 @@ def init_hub(self):
721
721
if self .restore_engines :
722
722
self .hub ._load_engine_state ()
723
723
724
- def launch_python_scheduler (self , scheduler_args , children ):
724
+ def launch_python_scheduler (self , name , scheduler_args , children ):
725
725
if 'Process' in self .mq_class :
726
726
# run the Python scheduler in a Process
727
- q = Process (target = launch_scheduler , kwargs = scheduler_args )
728
- q .daemon = True
727
+ q = Process (
728
+ target = launch_scheduler ,
729
+ kwargs = scheduler_args ,
730
+ name = name ,
731
+ daemon = True ,
732
+ )
729
733
children .append (q )
730
734
else :
731
735
# single-threaded Controller
@@ -750,12 +754,16 @@ def get_python_scheduler_args(
750
754
}
751
755
752
756
def launch_broadcast_schedulers (self , monitor_url , children ):
753
- def launch_in_thread_or_process (scheduler_args ):
757
+ def launch_in_thread_or_process (scheduler_args , depth , identity ):
754
758
755
759
if 'Process' in self .mq_class :
756
760
# run the Python scheduler in a Process
757
- q = Process (target = launch_broadcast_scheduler , kwargs = scheduler_args )
758
- q .daemon = True
761
+ q = Process (
762
+ target = launch_broadcast_scheduler ,
763
+ kwargs = scheduler_args ,
764
+ name = f"BroadcastScheduler(depth={ depth } , id={ identity } )" ,
765
+ daemon = True ,
766
+ )
759
767
children .append (q )
760
768
else :
761
769
# single-threaded Controller
@@ -805,7 +813,7 @@ def recursively_start_schedulers(identity, depth):
805
813
self .client_url (BroadcastScheduler .port_name , outgoing_id2 ),
806
814
]
807
815
)
808
- launch_in_thread_or_process (scheduler_args )
816
+ launch_in_thread_or_process (scheduler_args , depth = depth , identity = identity )
809
817
if not is_leaf :
810
818
recursively_start_schedulers (outgoing_id1 , depth + 1 )
811
819
recursively_start_schedulers (outgoing_id2 , depth + 1 )
@@ -823,6 +831,7 @@ def init_schedulers(self):
823
831
# maybe_inproc = 'inproc://monitor' if self.use_threads else monitor_url
824
832
# IOPub relay (in a Process)
825
833
q = mq (zmq .PUB , zmq .SUB , zmq .PUB , b'N/A' , b'iopub' )
834
+ q .name = "IOPubScheduler"
826
835
q .bind_in (self .client_url ('iopub' ))
827
836
q .setsockopt_in (zmq .IDENTITY , ident + b"_iopub" )
828
837
q .bind_out (self .engine_url ('iopub' ))
@@ -833,6 +842,7 @@ def init_schedulers(self):
833
842
834
843
# Multiplexer Queue (in a Process)
835
844
q = mq (zmq .ROUTER , zmq .ROUTER , zmq .PUB , b'in' , b'out' )
845
+ q .name = "DirectScheduler"
836
846
837
847
q .bind_in (self .client_url ('mux' ))
838
848
q .setsockopt_in (zmq .IDENTITY , b'mux_in' )
@@ -844,6 +854,7 @@ def init_schedulers(self):
844
854
845
855
# Control Queue (in a Process)
846
856
q = mq (zmq .ROUTER , zmq .ROUTER , zmq .PUB , b'incontrol' , b'outcontrol' )
857
+ q .name = "ControlScheduler"
847
858
q .bind_in (self .client_url ('control' ))
848
859
q .setsockopt_in (zmq .IDENTITY , b'control_in' )
849
860
q .bind_out (self .engine_url ('control' ))
@@ -859,6 +870,7 @@ def init_schedulers(self):
859
870
if scheme == 'pure' :
860
871
self .log .warn ("task::using pure DEALER Task scheduler" )
861
872
q = mq (zmq .ROUTER , zmq .DEALER , zmq .PUB , b'intask' , b'outtask' )
873
+ q .name = "TaskScheduler(pure)"
862
874
# q.setsockopt_out(zmq.HWM, hub.hwm)
863
875
q .bind_in (self .client_url ('task' ))
864
876
q .setsockopt_in (zmq .IDENTITY , b'task_in' )
@@ -868,11 +880,12 @@ def init_schedulers(self):
868
880
q .daemon = True
869
881
children .append (q )
870
882
elif scheme == 'none' :
871
- self .log .warn ("task::using no Task scheduler" )
883
+ self .log .warning ("task::using no Task scheduler" )
872
884
873
885
else :
874
886
self .log .info ("task::using Python %s Task scheduler" % scheme )
875
887
self .launch_python_scheduler (
888
+ 'TaskScheduler' ,
876
889
self .get_python_scheduler_args ('task' , TaskScheduler , monitor_url ),
877
890
children ,
878
891
)
@@ -944,6 +957,14 @@ def start(self):
944
957
# otherwise signal-handling will fire multiple times
945
958
for child in self .children :
946
959
child .start ()
960
+ if hasattr (child , 'launcher' ):
961
+ # apply name to actual process/thread for logging
962
+ setattr (child .launcher , 'name' , child .name )
963
+ if not self .use_threads :
964
+ process = getattr (child , 'launcher' , child )
965
+ self .log .debug (f"Started process { child .name } : { process .pid } " )
966
+ else :
967
+ self .log .debug (f"Started thread { child .name } " )
947
968
948
969
self .init_signal ()
949
970
0 commit comments