barrust/mediawiki

No rate limiting with rate_limit_wait less than 1 second

Bomme opened this issue · 0 comments

Bomme commented

Casting the wait_time value to int results in no rate limiting if the specified rate_limit_wait is less than 1 second (which is the default).
The conversion [in this line](https://github.com/barrust/mediawiki/blob/v0.7.1/mediawiki/mediawiki.py#L863 (time.sleep(int(wait_time.total_seconds()))) will floor all values to zero that are less than 1 second.

>>> from datetime import timedelta
>>> wait_time = timedelta(milliseconds=501)
>>> int(wait_time.total_seconds())
0

Simply using the float value works fine:

>>> import time
>>> time.sleep(timedelta(milliseconds=50).total_seconds())