vdirsyncer icon indicating copy to clipboard operation
vdirsyncer copied to clipboard

Add a timeout for unreachable server

Open cweagans opened this issue 10 years ago • 18 comments

I use Davmail via my company's VPN. When I'm not connected to the VPN, vdirsyncer will just hang while it tries to connect to a server it will never be able to connect to. Is there any way to tell vdirsyncer to only wait n seconds before giving up on syncing from a particular storage? Even globally, this option would be useful.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

cweagans avatar Jul 28 '15 15:07 cweagans

What's the problem with vdirsyncer just timing out?

On 28 July 2015 17:39:54 CEST, Cameron Eagans [email protected] wrote:

I use Davmail via my company's VPN. When I'm not connected to the VPN, vdirsyncer will just hang while it tries to connect to a server it will never be able to connect to. Is there any way to tell vdirsyncer to only wait n seconds before giving up on syncing from a particular storage? Even globally, this option would be useful.


Reply to this email directly or view it on GitHub: https://github.com/untitaker/vdirsyncer/issues/249

Sent from my phone. Please excuse my brevity.

untitaker avatar Jul 29 '15 18:07 untitaker

@cweagans ?

untitaker avatar Aug 11 '15 20:08 untitaker

Basically, I'm just asking for a configurable timeout or a significantly shorter one (5 seconds?). Waiting 5 minutes or whatever it is set to is annoying when I'm trying to get things done.

cweagans avatar Aug 11 '15 20:08 cweagans

Adding that option wouldn't be a big deal, but I still don't really understand why you can't just let vdirsyncer time out in the background. It's not like it's blocking you from doing any other work.

untitaker avatar Aug 11 '15 20:08 untitaker

I use davmail, and it's more likely to crash if I'm not connected to my company's VPN and I try to download calendar entries. I also only use vdirsyncer in the foreground. I don't have it set up on a cron job or anything. It does actually block me for a few minutes :)

cweagans avatar Aug 11 '15 20:08 cweagans

Can't you just hit ^C? I'd merge a PR for that option though.

untitaker avatar Aug 11 '15 20:08 untitaker

I tried that, but it doesn't actually stop the process.

cweagans avatar Aug 11 '15 20:08 cweagans

It does work if you use Python 3. I've not figured out how to fix this situation on Python 2.

untitaker avatar Aug 11 '15 20:08 untitaker

@cweagans Is this still an issue? I'd like to remove Python 2 support sometime (see #219), so I'm not sure if this feature is really needed as I'm sure you can hit ^C in Py3.

untitaker avatar Mar 09 '16 16:03 untitaker

Personally, I think a 5 min timeout is way too long. If you disagree, feel free to close this.

cweagans avatar Mar 09 '16 18:03 cweagans

I've just looked at the requests docs, and it doesn't seem there is any timeout. I'll just leave this open for now. On the one hand I don't really want to introduce more knobs, on the other hand I don't know what a good default would be :(

untitaker avatar Mar 09 '16 19:03 untitaker

I think 10-15 seconds is a reasonable default for just being able to connect to the server.

cweagans avatar Mar 09 '16 19:03 cweagans

This might be bikesheding, but IMHO, 120 seconds should be fine. That would cover even very high-latency connections, but avoid an indefinite wait.

ctrl+c might not be possible everywhere; I run vdirsyncer sync via cron every five minutes, so I guess that this issue might result in some infinitely dead processed out there.

WhyNotHugo avatar Mar 09 '16 22:03 WhyNotHugo

Hmm, agreed.

Maybe we should still make it configurable, like most options that remotestorage, *dav and http share.

untitaker avatar Mar 09 '16 22:03 untitaker

So here's the plan: Default is 120 secs (no strong opinion) and configurable using new timeout param for the storages mentioned above. Unsure if combined parameter a la (connect_timeout, read_timeout) like it's done in requests is a good idea. Opinions?

untitaker avatar Mar 09 '16 22:03 untitaker

I'm happy with that.

cweagans avatar Mar 09 '16 22:03 cweagans

I experienced a vdirsyncer process that hung because of server issues for multiple hours. Should there have been a timeout? It was a problem because subsequent runs (from cron) could not proceed because of "database is locked".

tvogel avatar Dec 02 '22 03:12 tvogel

As a workaround, I am now using the timeout command in my crontab to limit execution time.

tvogel avatar Dec 12 '22 13:12 tvogel