How do you use ArgumentParser with async ParsableCommand.run()?

I've been trying to use the ArgumentParser module with the new async/await concurrency, but whenever I change the ParsableCommand.run() implementation to async, the app just prints the help message and exits. It's as if the run() implementation is never invoked!

Has anyone else had any luck using ArgumentParser with async?

i ran into the same issue a little while back. long story short, ParsableCommand is providing a default non-async implementation of run(), and this will be preferred as the main function of the app, depending on platform. so i actually had the same async app that worked fine on ubuntu, but not on amazon linux.

the least-hacky way i know of solving this is to enable the AsyncParsableCommand API and use that instead. i wrote a short guide on how to do that here.

4 Likes

Iā€™m surprised this still not merged into an oficial release. :slightly_frowning_face: :

2 Likes

That turned out to be exactly what I needed, thank you!

BTW, the async branch of ArgumentParser isn't tagged, so you need to specify an exact commit hash if you have any other dependencies using ArgumentParser, otherwise you won't get the version that has AsyncParsableCommand. You might want to add that to the guide.

1 Like

Do we know if there is something blocking that branch to be merged besides just time?