@@ -334,7 +334,7 @@ def increment_progress(self, amount: int):
334
334
DeprecationWarning ,
335
335
stacklevel = 2 ,
336
336
)
337
- return self .increment_value (amount )
337
+ self .increment_value (amount )
338
338
339
339
def increment_value (self , amount : int ):
340
340
"""Increment the task progress by adding the specified amount to the current value.
@@ -353,14 +353,17 @@ def update_progress(self, value: int, value_step: int = None, rate_limit: int =
353
353
)
354
354
self .update_value (value , value_step , rate_limit )
355
355
356
- def update_value (self , value : int , value_step : int = None , rate_limit : int = None ):
356
+ def update_value (self , value : int , value_step : int = None , rate_limit : int = None ) -> bool :
357
357
"""Update task progress.
358
358
359
359
Arguments:
360
360
value: The new value to set.
361
361
value_step: The minimum change in value required to trigger an update.
362
362
rate_limit: The minimum interval between updates in seconds.
363
363
364
+ Returns:
365
+ bool: True if the task was updated, False otherwise
366
+
364
367
If either `value_step` or `rate_limit` is set, the task will only be updated if the
365
368
specified conditions are met. If both are set, the task will be updated if either
366
369
condition is met.
@@ -370,6 +373,8 @@ def update_value(self, value: int, value_step: int = None, rate_limit: int = Non
370
373
value_check = value_step and self ._check_update_value_interval (value , value_step )
371
374
if skip_check or time_check or value_check :
372
375
self .update (value = value )
376
+ return True
377
+ return False
373
378
374
379
def set_value_max (self , value_max : int ):
375
380
"""Set the `value_max`."""
@@ -424,16 +429,21 @@ def tag(self, tags: dict[str, str]):
424
429
"""Add tags to the task."""
425
430
self .update (tags = tags )
426
431
427
- def ping (self , rate_limit = None ):
432
+ def ping (self , rate_limit = None ) -> bool :
428
433
"""Update the task without changing any values. This can be used in conjunction
429
434
with 'stale_timeout' to indicate that the task is still running.
430
435
431
436
Arguments:
432
437
rate_limit: The minimum interval between pings in seconds. If set this will only
433
438
update the task if the last update was more than `rate_limit` seconds ago.
439
+
440
+ Returns:
441
+ bool: True if the task was updated, False otherwise
434
442
"""
435
443
if self ._check_update_time_interval (rate_limit ):
436
444
self .update ()
445
+ return True
446
+ return False
437
447
438
448
@property
439
449
def tags (self ):
0 commit comments