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

Support specifying a timeout for network operations #18

Closed
leoschwarz opened this issue May 2, 2018 · 2 comments
Closed

Support specifying a timeout for network operations #18

leoschwarz opened this issue May 2, 2018 · 2 comments

Comments

@leoschwarz
Copy link

I think libraries checking for a new version on import should do so either with a timeout or asynchronously. I've just experienced my code not working anymore, because as a concrete example I've tried to import meshio on a bad network and got stuck at this line https://github.com/nschloe/meshio/blob/0142bd97547a30538682c0701cce813dc2a85052/meshio/__init__.py#L20 .

Of course it should be optional as it otherwise might constitute a breaking change. I guess testing this functionality is a bit difficult, an easy option would be try making a request to httpbin.org 's /delay/:n endpoint, or no test at all.

@nschloe
Copy link
Owner

nschloe commented May 3, 2018

Alrighty then, I've added a time out of 1.0 seconds.

I've thought about making this whole thing async, but if you have a bad network this might not help you much: meshio conversions are usually pretty fast, and Python would have to wait for the request to finish regardless.

@nschloe nschloe closed this as completed May 3, 2018
@leoschwarz
Copy link
Author

Vielen Dank für den schnellen Patch!

The main problem is when I'm sitting on a network with misconfigured DNS or that is eating packets, the operation blocks indefinitely. I'll try the newer version with the problematic wifi again when I get to it, but from my side you could have set the timeout higher if you want, e.g. 5-10s would already be enough as I think what matters is just having a timeout at all. (I'm not sure if with 1s it will be enough for the properly configured network.)

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

2 participants