revolut-python icon indicating copy to clipboard operation
revolut-python copied to clipboard

Infinite loop in get_account_transactions

Open ishfx opened this issue 5 years ago • 1 comments

Hey,

I have a script using your wonderful library which has been working great so far. When i ran it earlier this day, i got an unexpected result; it hang.

I had to dig to find out why it got into this state.

The issue comes from the method get_account_transactions. https://github.com/tducret/revolut-python/blob/master/revolut/init.py#L186

get_account_transactions never breaks from the infinite loop because the revolut api always returns a transaction. To be more precise, the first call to the api (so first loop) returns N transactions, to param is updated with the datetime of the last retrieved transaction, then the second loop (and those after) always return 1 transaction => stuck in loop.

I don't understand the need for the loop here, are there any specific cases ?

Right now, i just removed the loop to solve the issue because the first api call returns the requested transactions.

Thanks in advance.

ishfx avatar Jan 03 '21 01:01 ishfx

Thank you, @IshFx, for a good spot. Feel free to open a PR with changes, but make sure it accounts for transaction pagination. I agree with you that the loop is not well/safely implemented and can be refactored. Maybe @cosmincc(https://github.com/tducret/revolut-python/commit/2e816d205ebbf755527abb6dcde99382c4cd1b4c) can take a look at that?

leikoilja avatar Jan 08 '21 08:01 leikoilja