Repository: PrefectHQ/prefect

Issue:
Cancelled flow run still has running task runs
## Description
<!-- A clear description of the bug -->
This may be specific for the weird task and flow I use for testing a lot of things in the UI but wanted to raise in case it's not. (Especially because it has implications for restart from cancelled in the UI).  
I have a task that involves time.sleep() and sleeps for 10+ minutes.  If I cancel a flow run that includes that task, the flow run enters a cancelled state while the task run is still running.  Eventually the task run is picked up by the zombiekiller as it has no heartbeat and fails. 

## Expected Behavior
<!-- What did you expect to happen instead? -->
Expect that the task run would enter a finished state (cancelled or the state from that run) before (or at least at the same time as) the flow run does. 


## Reproduction
<!-- A minimal example that exhibits the behavior. -->
1. Register the following flow: 
```
from prefect import task, Flow
import time

@task
def sleep():
    time.sleep(750)

with Flow(name='simple-sleep') as flow:
    sleep()

flow.register('PROJECTNAME')
```

2. Run the flow 
3. Cancel it (using the UI or the cancel_flow_run mutation). 


## Environment
<!-- Any additional information about your environment
This is run on a local agent on my mac using a cloud developer account and core 0.13.9

<img width="968" alt="Screen Shot 2020-10-02 at 12 38 38 PM" src="https://user-images.githubusercontent.com/40272060/94947808-45640180-04ac-11eb-9f50-8db4abfd4427.png">


Optionally run `prefect diagnostics` from the command line and paste the information here. -->



Discussion:
Weirdly my environment details aren't showing for me.  Copying in here in case others can't see them:
_This is run on a local agent on my mac using a cloud developer account and core 0.13.9_

Resolving patch:
diff --git a/src/prefect/engine/cloud/flow_runner.py b/src/prefect/engine/cloud/flow_runner.py
--- a/src/prefect/engine/cloud/flow_runner.py
+++ b/src/prefect/engine/cloud/flow_runner.py
@@ -197,22 +197,18 @@ def interrupt_if_cancelling() -> None:
                         flow_run_version = flow_run_info.version
                         # If not already leaving context, raise KeyboardInterrupt in the main thread
                         if not exiting_context:
-                            if hasattr(signal, "raise_signal"):
-                                # New in python 3.8
-                                signal.raise_signal(signal.SIGINT)  # type: ignore
+                            if os.name == "nt":
+                                # This doesn't actually send a signal, so it will only
+                                # interrupt the next Python bytecode instruction - if the
+                                # main thread is blocked in a c extension the interrupt
+                                # won't be seen until that returns.
+                                from _thread import interrupt_main
+
+                                interrupt_main()
                             else:
-                                if os.name == "nt":
-                                    # This doesn't actually send a signal, so it will only
-                                    # interrupt the next Python bytecode instruction - if the
-                                    # main thread is blocked in a c extension the interrupt
-                                    # won't be seen until that returns.
-                                    from _thread import interrupt_main
-
-                                    interrupt_main()
-                                else:
-                                    signal.pthread_kill(
-                                        threading.main_thread().ident, signal.SIGINT  # type: ignore
-                                    )
+                                signal.pthread_kill(
+                                    threading.main_thread().ident, signal.SIGINT  # type: ignore
+                                )
                         break
                     elif exiting_context:
                         break


Test patch: