SouthwestCheckin icon indicating copy to clipboard operation
SouthwestCheckin copied to clipboard

limit safe_request retries

Open jpetermans opened this issue 6 years ago • 4 comments

Prevent unnecessary requests to the reservation server when reservation data is incorrect or the server is unavailable. Multiple repeat requests only necessary for checkin().

@pyro2927, I set the number of retries under checkin() based on CHECKIN_EARLY_SECONDS and CHECKIN_INTERVAL_SECONDS. Seemed like a sane window for retries, but feel free to change. With this and recent your refactor I put some static settings in the init of the reservation class. This made that info easier to reference in both files in this commit.

jpetermans avatar Feb 27 '19 21:02 jpetermans

@pyro2927 I had a chance for a test with this PR and I think I've got the retries on the wrong request to the server. Currently multiple tries are only on the final attempt in checkin. However, it seems the request from get_checkin_data also fails with a BAD_REQUEST if done too early for check-in and the script exits early.

I'm not sure if just get_checkin_data needs to run multiple times if a little early or if the final check in attempt in checkin also does. Can you confirm if one or the other, or both need multiple retries if requests are made slightly earlier than checkin_time?

jpetermans avatar Mar 01 '19 15:03 jpetermans

@jpetermans I've found it useful for both. Southwest seems to lie more or less, as I wouldn't consider an early-yet-valid to checkin to warrant BAD_REQUEST, yet they seem to. You can keep slinging the same request at them and eventually it'll work. Not sure a better approach on how to deal with it outside of waiting X seconds AFTER the checkin window, but that feels to go against the whole point of the script.

pyro2927 avatar Mar 03 '19 16:03 pyro2927

Code Climate has analyzed commit 2f564b9f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 89.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 91.4% (0.0% change).

View more on Code Climate.

qlty-cloud-legacy[bot] avatar Mar 03 '19 22:03 qlty-cloud-legacy[bot]

I agree with you on the server response, and script still should keep trying right up to when the check-in window opens. Hopefully this PR accomplishes that without hitting the server with a lot of true bad requests, just check-in attempts.

Two additional changes with this latest commit:

  • Script retries with get_checkin_data which also returns BAD_REQUEST if it hits the server a little early.
  • safe_requests tests for ERROR__AIR_TRAVEL__BEFORE_CHECKIN_WINDOW response from server which is when retries are needed.

jpetermans avatar Mar 03 '19 22:03 jpetermans