allow async output on the most recent request

Keeps track of the most recent request, so async output is still allowed
schedule async flush

allows threadsafe flush from background threads
Merge pull request #5668 from minrk/async-output

allow async output on the most recent request
Merge pull request #5669 from minrk/flush-thread-output

allows threadsafe sys.stdout.flush from background threads