Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sporadic ansible-runner macOS bug and remove extra listener thread
It was found that on macOS a sporadic failure would occur where the internal listener, while started, wouldn't actually start listening right away, causing the listener to miss the file we were waiting for. The listen gem [creates an internal thread, `@run_thread`][1], which on most target systems is where the actually listening is done. However, [on macOS, `@run_thread` creates a second thread, `@worker_thread`][2], which does the actual listening. It's possible that although the listener is started, the @worker_thread hasn't actually started yet. This leaves a window where the target_path we are waiting on can actually be created before the `@worker_thread` is started and we "miss" the creation of the target_path. This commit ensures that we won't move on until that thread is ready, further ensuring we can't miss the creation of the target_path. Ansible::Runner#wait_for was also creating an extra thread when starting the listener, but this thread is unnecessary as the listen gem creates its own internal thread under the covers. [1]: https://github.com/guard/listen/blob/f186b2fa159a2458f3ff7e8680c3a4fcbdc636d1/lib/listen/adapter/base.rb#L75 [2]: https://github.com/guard/listen/blob/f186b2fa159a2458f3ff7e8680c3a4fcbdc636d1/lib/listen/adapter/darwin.rb#L49
- Loading branch information