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

Using non monotonic functions to calculate elapsed time

Open hagai-auro opened this issue 7 years ago • 1 comments

on master (commit 9ac3cb1ec220ff9968a8b003b02e98dd11cc486b) https://github.com/dpkp/kafka-python/blob/master/kafka/consumer/group.py , method def poll(self, timeout_ms=0, max_records=None) uses time.time() to calculate elapsed time. time.time() does not return a monotonic clock , and therefore the elapsed time calculation could yield unexpected results.

>>> time.get_clock_info('time') namespace(adjustable=True, implementation='clock_gettime(CLOCK_REALTIME)', monotonic=False, resolution=1.0000000000000002e-06)

the time module has several monotonic times available, but I don't believe they're available for python 2, which this library supports

hagai-auro avatar Jul 16 '18 23:07 hagai-auro

Agreed, it'd be nice to change to a monotonic clock. But as you also note, this will be easiest to implement after we drop Python 2 support (which may be a little while): https://github.com/dpkp/kafka-python/issues/1927

jeffwidman avatar Feb 12 '20 21:02 jeffwidman