@@ -102,7 +102,9 @@ def write_messages(workflow, job_id, messages, event_time):
102
102
_append_job_status_file (workflow , job_id , event_time , messages )
103
103
104
104
105
- def send_messages (workflow , job_id , messages , event_time ):
105
+ def send_messages (
106
+ workflow : str , job_id : str , messages : List [list ], event_time : str
107
+ ) -> None :
106
108
workflow = os .path .normpath (workflow )
107
109
try :
108
110
pclient = get_client (workflow )
@@ -111,23 +113,24 @@ def send_messages(workflow, job_id, messages, event_time):
111
113
# either the workflow is stopped or the contact file is not present
112
114
# on the job host (i.e. comms method is polling)
113
115
# eitherway don't try messaging
114
- pass
115
- except Exception :
116
- # Backward communication not possible
116
+ return
117
+ except Exception as exc :
118
+ print ( f" { type ( exc ). __name__ } : { exc } " , file = sys . stderr )
117
119
if cylc .flow .flags .verbosity > 1 :
118
120
import traceback
119
121
traceback .print_exc ()
120
- else :
121
- mutation_kwargs = {
122
- 'request_string' : MUTATION ,
123
- 'variables ' : {
124
- 'wFlows ' : [ workflow ],
125
- 'taskJob ' : job_id ,
126
- 'eventTime ' : event_time ,
127
- 'messages ' : messages ,
128
- }
122
+ # cylc message shouldn't fail if the client can't initialize.
123
+ return
124
+ mutation_kwargs = {
125
+ 'request_string ' : MUTATION ,
126
+ 'variables ' : {
127
+ 'wFlows ' : [ workflow ] ,
128
+ 'taskJob ' : job_id ,
129
+ 'eventTime ' : event_time ,
130
+ 'messages' : messages ,
129
131
}
130
- pclient ('graphql' , mutation_kwargs )
132
+ }
133
+ pclient ('graphql' , mutation_kwargs )
131
134
132
135
133
136
def _append_job_status_file (workflow , job_id , event_time , messages ):
@@ -138,7 +141,8 @@ def _append_job_status_file(workflow, job_id, event_time, messages):
138
141
try :
139
142
job_status_file = open (job_log_name + '.status' , 'a' ) # noqa: SIM115
140
143
# TODO: niceify read/write/appending messages to this file
141
- except IOError :
144
+ except IOError as exc :
145
+ print (f"{ type (exc ).__name__ } : { exc } " , file = sys .stderr )
142
146
if cylc .flow .flags .verbosity > 1 :
143
147
import traceback
144
148
traceback .print_exc ()
0 commit comments