tidy3d
tidy3d copied to clipboard
Add timeout to web functions
Running the linter, it complains that the requests
calls don't have a timeout. Could we add these if applicable?
For now, I disabled the missing-timeout
in the .pylintrc
file, so we can remove that when this is fixed.
************* Module tidy3d.plugins.dispersion.fit
tidy3d/plugins/dispersion/fit.py:649:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.plugins.dispersion.fit_web
tidy3d/plugins/dispersion/fit_web.py:157:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/plugins/dispersion/fit_web.py:164:15: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/plugins/dispersion/fit_web.py:265:15: W3101: Missing timeout argument for method 'requests.post' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.web.httputils
tidy3d/web/httputils.py:90:11: W3101: Missing timeout argument for method 'requests.post' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:98:11: W3101: Missing timeout argument for method 'requests.put' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:106:11: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
tidy3d/web/httputils.py:114:11: W3101: Missing timeout argument for method 'requests.delete' can cause your program to hang indefinitely (missing-timeout)
************* Module tidy3d.web.auth
tidy3d/web/auth.py:28:11: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
I'm not sure what is the right number for timeout, due to Weiliang's requirement, fit method could run in couple of minutes. If the number is less than that, it will be forcely interrupted. @weiliangjin2021 do you have any idea about this?
In the meanwhile, the web version of fitting is online, I'm planning to add the api into python client, hence we could retire this fitter from it.
ok, I think just an upper bound would be ok for the fitter. Note that the main webapi Simulation functions also require timeout parameter (web.upload()
for example).
Can we have different timeout values for different functions?
Yea, it's just a kwarg to requests.get
, requests.post
, etc. https://requests.readthedocs.io/en/latest/api/#requests.request see timeout
I think we can set the timeout for fitter to be 2 min.
consolidating in #544