Weird fix for a weird error that suddenly started on one of my machines.

```
Traceback (most recent call last):
  File "/usr/lib/python3.9/dist-packages/platypush/plugins/__init__.py", line 247, in _runner
    self.main()
  File "/usr/lib/python3.9/dist-packages/platypush/plugins/bluetooth/__init__.py", line 590, in main
    self._refresh_cache()
  File "/usr/lib/python3.9/dist-packages/platypush/plugins/bluetooth/__init__.py", line 146, in _refresh_cache
    get_entities_engine().wait_start()
  File "/usr/lib/python3.9/dist-packages/platypush/entities/__init__.py", line 48, in get_entities_engine
    time_start = time()
TypeError: 'module' object is not callable
```

There isn't a single reason in this world for this error to happen.

If I do `from time import time`, then `t = time()` is 100% valid Python.

I have no clue of what may be causing it, but I hope that this will fix
it.
This commit is contained in:
Fabio Manganiello 2024-06-01 10:47:53 +02:00
parent ff60896625
commit b067430cd5

View file

@ -1,6 +1,6 @@
import logging import logging
import time
from threading import Event from threading import Event
from time import time
from typing import Collection, Optional from typing import Collection, Optional
from ._base import ( from ._base import (
@ -45,8 +45,8 @@ def get_entities_engine(timeout: Optional[float] = None) -> EntitiesEngine:
:param timeout: Timeout in seconds (default: None). :param timeout: Timeout in seconds (default: None).
""" """
time_start = time() time_start = time.time()
while not timeout or (time() - time_start < timeout): while not timeout or (time.time() - time_start < timeout):
if _engine: if _engine:
break break