yr.cancel

Contents

yr.cancel#

yr.cancel(obj_refs: ObjectRef | List[ObjectRef], allow_force: bool = True, allow_recursive: bool = False) None[source]#

Cancel a specified stateless request.

Note

Currently, passing an instance request will not trigger the corresponding cancel operation and will not result in an error.

Parameters:
  • obj_refs (Union[ObjectRef, List[ObjectRef]]) – The ObjectRef(s) of the stateless request to be stopped, either a single stateless request or multiple stateless requests.

  • allow_force (bool, optional) – Force stopping. Default is _DEFAULT_ALLOW_FORCE.

  • allow_recursive (bool, optional) – Allow recursion. Default is _DEFAULT_ALLOW_RECURSIVE.

Returns:

None.

Raises:

TypeError – If the parameter type is incorrect.

Examples

>>> import time
>>> import yr
>>> yr.init()
>>>
>>> @yr.invoke
>>> def func():
>>>     time.sleep(100)
>>>
>>> ret = func.invoke()
>>> yr.cancel(ret)
>>> yr.finalize()