Skip to content

Allow suspending fibers in destructors #11389

Closed
@nicolas-grekas

Description

@nicolas-grekas

Description

Right now, when trying to suspend the current fiber in a destructor, the engine throws "Cannot switch fibers in current execution context".

This has been discussed a bit with @trowski and @kelunik in nicolas-grekas/symfony#43 (review)

From that discussion, the reason is that the garbage collector would need to be made safe for re-entry from multiple fibers.

Not being able to do i/o (which is what fibers are most useful for) in destructors kinda reintroduces the “What color is your function?” problem, which fibers were designed to avoid.

I totally get that this might be challenging, but this limitation should be removed if possible. 🙏

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions