Rearrange launch_if_ready to avoid race condition in #2227 (#2288)
Rearrange launch_if_ready to avoid race condition in #2227 (#2288)

This commit moves both the launch lock and pending state check so that
all of launch_if_ready is protected by them. Previously, these only
protected the launch path, which meant that the dependency-failure
path was unprotected and could result in the misbehaviour described
in #2227.

Fixes #2227


Parsl/parsl,Parsl/parsl,Parsl/parsl,Parsl/parsl