Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def build(setup_kwargs: Any) -> None:
"src/zeroconf/_protocol/outgoing.py",
"src/zeroconf/_handlers/record_manager.py",
"src/zeroconf/_services/registry.py",
"src/zeroconf/_utils/time.py",
],
compiler_directives={"language_level": "3"}, # Python 3
),
Expand Down
6 changes: 3 additions & 3 deletions src/zeroconf/_listener.pxd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import cython

from ._protocol.incoming cimport DNSIncoming
from ._utils.time cimport current_time_millis, millis_to_seconds
Comment on lines +4 to +5
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have a lot of float conversions from the constants that we can't patch because it breaks the tests



cdef object millis_to_seconds
cdef object log
cdef object logging_DEBUG

from ._protocol.incoming cimport DNSIncoming


cdef class AsyncListener:

Expand Down
4 changes: 4 additions & 0 deletions src/zeroconf/_utils/time.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

cpdef current_time_millis()

cpdef millis_to_seconds(object millis)
4 changes: 3 additions & 1 deletion src/zeroconf/_utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import time

_float = float


def current_time_millis() -> float:
"""Current time in milliseconds.
Expand All @@ -33,6 +35,6 @@ def current_time_millis() -> float:
return time.monotonic() * 1000


def millis_to_seconds(millis: float) -> float:
def millis_to_seconds(millis: _float) -> float:
"""Convert milliseconds to seconds."""
return millis / 1000.0