Adding the following line at the end of sub BUILD in “MyClass.pm” seems to fix the problem:
Role::Tiny->apply_roles_to_object($self, $module);
So my guess is: roles are, by default, class-based, rather than object-based, so that once a role has been added to a class, the definition of that class doesn’t change. But with multiple threads, the problem doesn’t arise as the class definition is re-created for each new thread.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: Namespace weirdness with Parallel::ForkManager using 0 children
by Athanasius
in thread SOLVED [ create_class_with_roles() ]: Moo[se] namespace weirdness with conditionally composed-in Roles
by 1nickt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |