wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.62k stars 319 forks source link

`time.sleep` in Python 3.11 not working on macOS #472

Open maneyko opened 1 month ago

maneyko commented 1 month ago

There seems to have been a change between Python 3.10 and 3.11 that breaks time.sleep when using libfaketime.

Steps to reproduce:

Dockerfile:

FROM python:3.10-slim-bullseye

ENV FAKETIME_TIMESTAMP_FILE="/faketimerc"
ENV LD_PRELOAD=/lib/faketime.so

RUN apt update && \
  apt install -y --no-install-recommends \
  libfaketime && \
  cp /usr/lib/*/faketime/libfaketimeMT.so.1 /lib/faketime.so && \
  echo '+0 x1' > /faketimerc
docker build -t libfaketime-python3.10 .

docker run --rm libfaketime-python3.10 python3 -c 'import time; time.sleep(1)'

Compared to Python 3.11.0 (after making the proper substitution in Dockerfile):

docker run --rm libfaketime-python3.11 python3 -c 'import time; time.sleep(1)'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
OSError: [Errno 22] Invalid argument