Prevent race condition in trying to collect result from DagFileProcessor (#11306)
Prevent race condition in trying to collect result from DagFileProcessor (#11306)

A rare race condition was noticed in the Scheduler HA PR where the
"test_dags_with_system_exit" test would occasionally fail with the
following symptoms:

- The pipe was "readable" as returned by
  `multiprocessing.connection.wait`
- On reading it yielded an EOFError, meaning the other side had closed
  the connection
- But the process was still alive/running

This previously would result in the Manager process dying with an error.

This PR makes a few changes:

- It ensures that the pipe is simplex, not duplex (we only ever send one
  data) as this is simpler
- We ensure that the "other" end of the pipe is correctly closed in both
  parent and child processes. Without this the pipe would be kept open
  (sometimes) until the child process had closed anyway.
- When we get an EOFError on reading and the process is still alive, we
  give it a few seconds to shut down cleanly, and then kill it.
dhuang/incubator-airflow,cfei18/incubator-airflow,nathanielvarona/airflow,apache/incubator-airflow,apache/incubator-airflow,Acehaidrey/incubator-airflow,DinoCow/airflow,lyft/incubator-airflow,sekikn/incubator-airflow,bolkedebruin/airflow,airbnb/airflow,apache/incubator-airflow,lyft/incubator-airflow,danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,mistercrunch/airflow,cfei18/incubator-airflow,danielvdende/incubator-airflow,bolkedebruin/airflow,bolkedebruin/airflow,mistercrunch/airflow,mrkm4ntr/incubator-airflow,dhuang/incubator-airflow,danielvdende/incubator-airflow,cfei18/incubator-airflow,mrkm4ntr/incubator-airflow,cfei18/incubator-airflow,apache/airflow,nathanielvarona/airflow,apache/airflow,airbnb/airflow,lyft/incubator-airflow,danielvdende/incubator-airflow,apache/incubator-airflow,nathanielvarona/airflow,nathanielvarona/airflow,cfei18/incubator-airflow,bolkedebruin/airflow,danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,Acehaidrey/incubator-airflow,DinoCow/airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow,mistercrunch/airflow,airbnb/airflow,Acehaidrey/incubator-airflow,cfei18/incubator-airflow,apache/airflow,DinoCow/airflow,danielvdende/incubator-airflow,sekikn/incubator-airflow,apache/airflow,bolkedebruin/airflow,mrkm4ntr/incubator-airflow,dhuang/incubator-airflow,nathanielvarona/airflow,dhuang/incubator-airflow,sekikn/incubator-airflow,apache/airflow,mistercrunch/airflow,DinoCow/airflow,mrkm4ntr/incubator-airflow,apache/airflow,lyft/incubator-airflow,sekikn/incubator-airflow,airbnb/airflow