Use time.time() instead of datetime.now() to measure elapsed time.
Both because it is more idiomatic and because we will soon start enforcing that all datetimes in Zulip are timezone aware.
This commit is contained in:
parent
b2ac1bca29
commit
6c47fa77b6
|
@ -38,6 +38,7 @@ import optparse
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import time
|
||||||
import signal
|
import signal
|
||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -762,8 +763,8 @@ def maybe_forward_to_zephyr(message):
|
||||||
# Don't try forward private messages with non-MIT users
|
# Don't try forward private messages with non-MIT users
|
||||||
# to MIT Zephyr.
|
# to MIT Zephyr.
|
||||||
return
|
return
|
||||||
timestamp_now = datetime.datetime.now().strftime("%s")
|
timestamp_now = int(time.time())
|
||||||
if float(message["timestamp"]) < float(timestamp_now) - 15:
|
if float(message["timestamp"]) < timestamp_now - 15:
|
||||||
logger.warning("Skipping out of order message: %s < %s" %
|
logger.warning("Skipping out of order message: %s < %s" %
|
||||||
(message["timestamp"], timestamp_now))
|
(message["timestamp"], timestamp_now))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue