File tree 5 files changed +33
-3
lines changed
5 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -722,6 +722,10 @@ worker_disconnect_delay
722
722
scheduler before removing it and marking all of its running tasks as
723
723
failed. Defaults to 60.
724
724
725
+ pause_enabled
726
+ If false, disables pause/unpause operations and hides the pause toggle from
727
+ the visualiser.
728
+
725
729
726
730
[sendgrid]
727
731
----------
Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ class scheduler(Config):
147
147
148
148
prune_on_get_work = parameter .BoolParameter (default = False )
149
149
150
+ pause_enabled = parameter .BoolParameter (default = True )
151
+
150
152
def _get_retry_policy (self ):
151
153
return RetryPolicy (self .retry_count , self .disable_hard_timeout , self .disable_window )
152
154
@@ -930,17 +932,23 @@ def disable_worker(self, worker):
930
932
def set_worker_processes (self , worker , n ):
931
933
self ._state .get_worker (worker ).add_rpc_message ('set_worker_processes' , n = n )
932
934
935
+ @rpc_method ()
936
+ def is_pause_enabled (self ):
937
+ return {'enabled' : self ._config .pause_enabled }
938
+
933
939
@rpc_method ()
934
940
def is_paused (self ):
935
941
return {'paused' : self ._paused }
936
942
937
943
@rpc_method ()
938
944
def pause (self ):
939
- self ._paused = True
945
+ if self ._config .pause_enabled :
946
+ self ._paused = True
940
947
941
948
@rpc_method ()
942
949
def unpause (self ):
943
- self ._paused = False
950
+ if self ._config .pause_enabled :
951
+ self ._paused = False
944
952
945
953
@rpc_method ()
946
954
def update_resources (self , ** resources ):
Original file line number Diff line number Diff line change @@ -158,6 +158,12 @@ var LuigiAPI = (function() {
158
158
} ) ;
159
159
} ;
160
160
161
+ LuigiAPI . prototype . isPauseEnabled = function ( callback ) {
162
+ jsonRPC ( this . urlRoot + '/is_pause_enabled' , { } , function ( response ) {
163
+ callback ( response . response . enabled ) ;
164
+ } ) ;
165
+ } ;
166
+
161
167
LuigiAPI . prototype . pause = function ( ) {
162
168
jsonRPC ( this . urlRoot + '/pause' ) ;
163
169
} ;
Original file line number Diff line number Diff line change @@ -1011,7 +1011,11 @@ function visualiserApp(luigi) {
1011
1011
$ ( document ) . ready ( function ( ) {
1012
1012
loadTemplates ( ) ;
1013
1013
1014
- luigi . isPaused ( createPauseToggle ) ;
1014
+ luigi . isPauseEnabled ( function ( enabled ) {
1015
+ if ( enabled ) {
1016
+ luigi . isPaused ( createPauseToggle ) ;
1017
+ }
1018
+ } ) ;
1015
1019
1016
1020
luigi . getWorkerList ( function ( workers ) {
1017
1021
$ ( "#workerList" ) . append ( renderWorkers ( workers ) ) ;
Original file line number Diff line number Diff line change @@ -229,6 +229,14 @@ def test_per_task_retry_policy(self):
229
229
task_9 .add_failure ()
230
230
self .assertTrue (task_9 .has_excessive_failures ())
231
231
232
+ @with_config ({'scheduler' : {'pause_enabled' : 'false' }})
233
+ def test_pause_disabled (self ):
234
+ s = luigi .scheduler .Scheduler ()
235
+ self .assertFalse (s .is_pause_enabled ()['enabled' ])
236
+ self .assertFalse (s .is_paused ()['paused' ])
237
+ s .pause ()
238
+ self .assertFalse (s .is_paused ()['paused' ])
239
+
232
240
233
241
class SchedulerWorkerTest (unittest .TestCase ):
234
242
def get_pending_ids (self , worker , state ):
You can’t perform that action at this time.
0 commit comments