GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Queue get timout parameter does not use a monotonic timer · Issue #104509 · python/cpython

Queue get timout parameter does not use a monotonic timer #104509

New issue
Copy link
New issue
Copy link
Closed
Closed
Queue get timout parameter does not use a monotonic timer#104509
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@fdirosa4188
fdirosa4188
opened on May 15, 2023
Issue body actions

It is clear looking at the source code that the Queue class uses time() and other non-monotonic timing sources. So if a queue get function is called with a timeout value and the system time is changed during that get it could end up waiting in the get for potentially days. The easiest way to reproduce is to set the timeout in the get to 5 minutes and which it is waiting on the queue to get an entry set the system clock back a few years. You will notice it will not exit the get.

Activity

  1. fdirosa4188
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 15, 2023
  2. arhadthedev
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on May 15, 2023
  3. arhadthedev commented on May 15, 2023

    @arhadthedev
    arhadthedev
    on May 15, 2023
    Member
    More actions

    @rhettinger (as a queue module expert)

  4. Agent-Hellboy commented on May 16, 2023

    @Agent-Hellboy
    Agent-Hellboy
    on May 16, 2023
    Contributor
    More actions

    do you have a reproducible code?
    it's monotonic

    cpython/Lib/queue.py

    Line 7 in 0bb61dd

    from time import monotonic as time

    As the issue template suggests you should share the reproducible code and the execution environment as well

  5. fdirosa4188 commented on May 17, 2023

    @fdirosa4188
    fdirosa4188
    on May 17, 2023
    Author
    More actions

    I am using Python 3.8.6 on Linux.
    Attached is python code that reproduces this problem. I set a specific date/time before the queue.get blocking call with a 10 second timeout and then change the date/time to a different date/time during the queue.get and it does not return after 10 seconds.

    There is a variable in the attached script called Make_It_Fail that is set to True. You can set it to False to see how the script works without date/time changes then set it to True to see how queue.get does not return after 10 seconds has elapsed.
    queue_timeout_test.py.txt

  6. aludwig98 commented on May 19, 2023

    @aludwig98
    aludwig98
    on May 19, 2023
    More actions

    This seems to have been resolved in Python 3.9, 3.10.

    See here: #85876

  7. fdirosa4188 commented on Jun 1, 2023

    @fdirosa4188
    fdirosa4188
    on Jun 1, 2023
    Author
    More actions

    I tried my queue_timeout.test.py script on Python 3.11 and it still does not timeout after 10 seconds. The queue.get() function blocks and seems to still be effected by changes to the system time on Linux.

    Reacted by Berk Orbay
  8. duaneg commented on May 24, 2025

    @duaneg
    duaneg
    on May 24, 2025
    Contributor
    More actions

    I can't reproduce the bug on current HEAD (v3.15-alpha), but then I can't reproduce it on v3.11.0 either. In both cases it produces the correct, expected output:

    Date/Time before queue.get(): 05/18/2024 23:34:43
    Calling queue get with blocking and 10 seconds timeout
    Date/Time during queue.get(): 05/18/2023 18:34:43
    10.00 seconds has elapsed and it is not blocked
    

    As @Agent-Hellboy says, the queue code itself uses a monotonic clock, and after #28662 so does the underlying lock the condition variable waits on.

    @fdirosa4188 please re-test and close if confirmed.

  9. picnixz
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on May 24, 2025
  10. picnixz
    closed this as completedon Jun 29, 2025
  11. picnixz
    reopened this on Jun 29, 2025
  12. picnixz
    closed this as completedon Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixesonly security fixes3.12only security fixesonly security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.