You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Poetry relies on the formatter's is_decorated property to be consistent when multiple threads query the property.
If one thread is in the middle of updating a section and has changed the formatter's is_decorated property via remove_format, a second thread may query it and get back an incorrect result.
If cleo is not thread-safe, the developers of poetry should be made aware, otherwise there may need to be changes to how remove_format and format work in relation to whether decorated output is supported in general vs decorated output is being emitted for the current format operation.
The text was updated successfully, but these errors were encountered:
vfazio
changed the title
Formatter's decorated property is temporarily disabled during remove_format breaking concurrent threads
Formatter's is_decorated property is temporarily disabled during remove_format breaking concurrent threads
Apr 28, 2024
vfazio
changed the title
Formatter's is_decorated property is temporarily disabled during remove_format breaking concurrent threads
Formatter's is_decorated property is temporarily disabled during remove_format breaking concurrent threads
Apr 28, 2024
Note that this seems to be an issue because the Formatter object is a shared instance across the IO objects, in Poetry's case StreamOutput and child SectionOutput objects (see StreamOutput.section)
One "workaround" would be to duplicate the Formatter object instead of sharing the object. That way the StreamOutput object could query its Formatter object independent of what the SectionOutput objects are using. This would allow the sections to manipulate their formatters independently and existing code may "just work" without having to make:
aware that while the formatter supports decorating, this operation should not be decorated.
If that's not ideal because formatter styles need to be kept in sync between the parent output object and child sections, maybe leverage a different private instance flag:
See python-poetry/poetry#9334
Poetry relies on the formatter's
is_decorated
property to be consistent when multiple threads query the property.If one thread is in the middle of updating a section and has changed the formatter's
is_decorated
property viaremove_format
, a second thread may query it and get back an incorrect result.If cleo is not thread-safe, the developers of poetry should be made aware, otherwise there may need to be changes to how
remove_format
andformat
work in relation to whether decorated output is supported in general vs decorated output is being emitted for the current format operation.The text was updated successfully, but these errors were encountered: