is a low level method. It starts the remote command and returns the file descriptors attached to its IO streams. Then you have to handle the IO and the finalization of the process. Don't use it unless you understand how it works.
For common SSH operations there are easier to use, higher level methods such as capture or system which run commands synchronously, or if you want to run a command asynchronously spawn.
I guess the issue here is a race condition because you are mounting the share asynchronously and CIFS is slow at setup.