Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout for remoter::batch #56

Open
philaris opened this issue Feb 6, 2020 · 5 comments
Open

timeout for remoter::batch #56

philaris opened this issue Feb 6, 2020 · 5 comments

Comments

@philaris
Copy link
Contributor

philaris commented Feb 6, 2020

Is there a way to specify a timeout for a remoter::batch request, e.g., in case the remote server is non-existent or is not running a remoter server? For example, the following code blocks forever:

remoter::batch(addr = 'non_existent_host', script = 'ls()')

I tried with R.utils::withTimeout, but is does not work, because I guess that the block happens in C code where user interrupts are not allowed.

@wrathematics
Copy link
Member

Interesting. I'm able to kill it with ctrl-c in a terminal:

> remoter::batch(addr = 'non_existent_host', script = 'ls()')
^CR_zmq_msg_recv errno: 4 strerror: Interrupted system call
Error in unserialize(rmsg) : read error

What OS and R interface are you using?

@philaris
Copy link
Contributor Author

philaris commented Feb 6, 2020

I can also kill it this way, but I would like to be able to detect if it takes too long. For example, this also blocks, even though I have specified a timeout of 2 seconds:

R.utils::withTimeout({ remoter::batch(addr = 'non_existent_server', script = 'ls()') }, timeout = 2.0, onTimeout = 'silent')

@philaris
Copy link
Contributor Author

philaris commented Feb 6, 2020

To be more specific, I can kill it if I run it in a cygwin terminal in windows with Rscript:

Rscript -e "remoter::batch(addr = 'non_existent_host', script = 'ls()')"

However, in RStudio, the following blocks and I cannot even kill it with the Stop icon:

remoter::batch(addr = 'non_existent_host', script = 'ls()')

@philaris
Copy link
Contributor Author

I have investigated a little more and it is not trivial to implement something with a timeout and non-blocking requests. This is due to the ZeroMQ settings used. In fact, with remoter if you make a batch request to a server that is not yet up and start the remoter server later, then the server replies! In practice, I check if port 55555 is open at the server (with a utility like nc) and hope that an actual remoter server is running at this port. We could close the issue if you want.

@snoweye
Copy link
Member

snoweye commented Feb 27, 2021

I add all socket options to pbdZMQ. The CONNECT_TIMEOUT with SNDTIMEO and RCVTIMEO may help on this, but it needs to rewrite a lot of server() and client() ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants