Skip to content

Add a .timeout attribute to CancelScope? #861

@njsmith

Description

@njsmith

Now that CancelScopes are becoming more exposed to users with #607 / #835, it occurred to me that it might be nice to have a weird magical .timeout property on them. The definition would be:

@property
def timeout(self):
    return max(0.0, self._deadline - trio.current_time())

@timeout.setter
def timeout(self, new_timeout):
    self.deadline = trio.current_time() + new_timeout

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