-
Notifications
You must be signed in to change notification settings - Fork 362
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
HTTPFilesystem has a race condition on data size between the open and read calls, if content changes at server between the 2 calls #1541
Comments
…etween the open and read class, if content changes at server between the 2 class
I am not convinced that this should be an issue. When the server changes state during our operations, ideally we should raise an exception rather than silently change our state. The size of a file is needed to be able to do any random access, so just saying In general, I agree that getting the size could be deferred at least until the first read and that the first read could also contain some data. I think all of the HTTP-based backends would support that, but it would take some reworking. |
I can see this would be consistent with the concept of a file on disk changing during a read, but one cannot help noticing that in the case of an HTTP "file", a
Yes, that would at least remove one round-trip to the server and reduce the probability of the race condition hitting the client. |
If you are interested, I would love to see an implementation. Else, keep pinging me util I do something about it. Any workflow like
should not need two requests. The server ought to tell us the total byte size at that point too, but I'm not sure this is guaranteed.
|
Unless you feel like trying to implement my suggestion, do keep pinging me until I have time to do something about it myself. |
One way to avoid this race condition is to |
The following script reproduces the issues
The script spins up an http server that makes the json content 1 chat longer every 1s.
Then the client bit hits the url with a 1s
sleep
between theopen
andread
calls. The json parsing immediately fails because the terminating{
gets chopped.For good measure the same test url is also hit with a
requests.get
call that does not seem to have any issues.The text was updated successfully, but these errors were encountered: