import random
import sys
import time

import pytest

import ray
from ray.exceptions import TaskCancelledError, RayTaskError, \
                           GetTimeoutError, WorkerCrashedError, \
                           ObjectLostError
from ray.test_utils import SignalActor


def valid_exceptions(use_force):
    if use_force:
        return (RayTaskError, TaskCancelledError, WorkerCrashedError,
                ObjectLostError)
    else:
        return (RayTaskError, TaskCancelledError)


@pytest.mark.parametrize("use_force", [True, False])
def test_cancel_chain(ray_start_regular, use_force):
    signaler = SignalActor.remote()

    @ray.remote