Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semaphore.acquire() timeout parameter #39617

Closed
hdima mannequin opened this issue Nov 28, 2003 · 9 comments
Closed

Semaphore.acquire() timeout parameter #39617

hdima mannequin opened this issue Nov 28, 2003 · 9 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@hdima
Copy link
Mannequin

hdima mannequin commented Nov 28, 2003

BPO 850728
Nosy @pitrou, @asvetlov, @Bluehorn
Files
  • threading.diff: Lib/threading.py, Doc/lib/libthreading.tex
  • sem_timeout.diff: updated patch for py3k
  • sem_timeout_trunk.diff: diff for trunk (2.7)
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/pitrou'
    closed_at = <Date 2010-04-17.23:53:11.532>
    created_at = <Date 2003-11-28.12:47:33.000>
    labels = ['type-feature', 'library']
    title = 'Semaphore.acquire() timeout parameter'
    updated_at = <Date 2010-11-06.22:11:46.290>
    user = 'https://bugs.python.org/hdima'

    bugs.python.org fields:

    activity = <Date 2010-11-06.22:11:46.290>
    actor = 'torsten'
    assignee = 'pitrou'
    closed = True
    closed_date = <Date 2010-04-17.23:53:11.532>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2003-11-28.12:47:33.000>
    creator = 'hdima'
    dependencies = []
    files = ['5711', '16260', '16261']
    hgrepos = []
    issue_num = 850728
    keywords = ['patch']
    message_count = 9.0
    messages = ['44957', '44958', '99602', '99605', '100031', '100053', '103227', '103457', '120651']
    nosy_count = 5.0
    nosy_names = ['hdima', 'pitrou', 'aptshansen', 'asvetlov', 'torsten']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue850728'
    versions = ['Python 3.2']

    @hdima
    Copy link
    Mannequin Author

    hdima mannequin commented Nov 28, 2003

    New optional timeout parameter for Semaphore.acquire().

    acquire(block=True, timeout=None)

    When invoked with blocking set to true and timeout set to
    a positive number, it blocks at most timeout seconds
    and return false if the internal counter is still zero;
    otherwise return true.

    @hdima hdima mannequin added stdlib Python modules in the Lib dir labels Nov 28, 2003
    @aptshansen
    Copy link
    Mannequin

    aptshansen mannequin commented Mar 16, 2007

    This applies cleanly against the HEAD, and passes all of the threading tests. I don't see any reason NOT to have a timeout on the Semaphores, and the implementation is clean enough.

    I do think that it should have some tests written since its a newish feature before being accepted, though.

    @devdanzin devdanzin mannequin added type-feature A feature request or enhancement labels Feb 14, 2009
    @Bluehorn
    Copy link
    Mannequin

    Bluehorn mannequin commented Feb 19, 2010

    I have been bitten by this omission from the python libs recently. I ended up copying the code from this diff into my script.

    I'd rather have this available with each python installation, so I updated the patch to include test cases as well as ReST documentation updates. Attached is the patch for Python 3.x (against current py3k). I'll send an updated patch for 2.7 as well.

    @Bluehorn
    Copy link
    Mannequin

    Bluehorn mannequin commented Feb 20, 2010

    Here is the diff for Python 2.7

    @Bluehorn
    Copy link
    Mannequin

    Bluehorn mannequin commented Feb 24, 2010

    I just noticed that the multiprocessing module supports the timeout parameter of Semaphore. So the patch would also fix the documentation of multiprocessing.Semaphore since it refers to threading.Semaphore.

    @pitrou
    Copy link
    Member

    pitrou commented Feb 24, 2010

    See bpo-7316 for something more or less related.

    @pitrou
    Copy link
    Member

    pitrou commented Apr 15, 2010

    2.7 is in (mostly) feature freeze mode, so I'm retargetting this to 3.2.
    (yes, this issue is very old; sorry)
    I will try to include it (or a variant thereof; the non-blocking + timeout combination doesn't make much sense, so I plan to forbid it) to the py3k branch soon.

    @pitrou
    Copy link
    Member

    pitrou commented Apr 17, 2010

    Modified patch committed in r80157 (py3k). Thank you!

    @pitrou pitrou closed this as completed Apr 17, 2010
    @pitrou pitrou closed this as completed Apr 17, 2010
    @Bluehorn
    Copy link
    Mannequin

    Bluehorn mannequin commented Nov 6, 2010

    Thanks for applying!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant