Skip to content

trio.Event.clear() is deprecated #61

Closed
@mehaase

Description

@mehaase

I am getting a deprecation warning:

.../python3.7/site-packages/trio_asyncio/base.py:718: TrioDeprecationWarning: trio.Event.clear is deprecated since Trio 0.12.0; use multiple Event objects or other synchronization primitives instead (python-trio/trio#637)

The deprecation references python-trio/trio#637 for more information. In short, Event.clear() is a foot gun that is prone to creating race conditions. The general recommendation is to create new events instead of clearing existing ones. It's not clear to me whether this recommendation would work in this circumstance:

self._stopped.clear()

The event is set as soon as its created, then cleared when control enter the asyncio main loop. This is an unsual way to use trio.Event, which makes me hesitant to say whether this is an easy to fix or not...

I also haven't checked if there are other uses of Event.clear() in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions