On Wed Sep 13 14:51:39 2023 +0000, Paul Gofman wrote:
It seems to me it doesn't fit nicely. Using it as is results in the need to decref it after in certain cases which looks clumsy and also may lead to spurious implicit mta creation and destruction which introduces a race. Mind that apartment_construct is called here only if there is an initialized (STA) apartment, and if there is none it only checks / refs existing one. And the check can't be done outside of critical section.
Or in fact I can use apartment_increment_mta_usage() by nesting critical section if you think is better.