Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect exception message inBarrier.__init__ #129403

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixeseasystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@Locked-chess-official

Description

@Locked-chess-official

Bug report

Bug description:

# Add a code block here, if required>>>importthreading>>>x=threading.Barrier(parties=0.5)Traceback (mostrecentcalllast):File"<pyshell#0>",line1,in<module>x=Barrier(parties=0.5)ValueError:partiesmustbe>0

Yes. As you see 0.5 is below 0.
To solve this problem, adding this sentence is viable.

classBarrier:"""Implements a Barrier.    Useful for synchronizing a fixed number of threads at known synchronization    points.  Threads block on 'wait()' and are simultaneously awoken once they    have all made that call.    """def__init__(self,parties,action=None,timeout=None):"""Create a barrier, initialised to 'parties' threads.        'action' is a callable which, when supplied, will be called by one of        the threads after they have all entered the barrier and just prior to        releasing them all. If a 'timeout' is provided, it is used as the        default for all subsequent 'wait()' calls.        #if not isinstance(parties, int):        #        raise TypeError("parties must be an integer")        if parties < 1:                raise ValueError("parties must be > 0")        """self._cond=Condition(Lock())self._action=actionself._timeout=timeoutself._parties=partiesself._state=0# 0 filling, 1 draining, -1 resetting, -2 brokenself._count=0

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixeseasystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp