The Voidspace Techie Blog

Gravatar Thanks for the encouragement! And please, if you have any suggestions, I would encourage you to join the google group, and share your input.


Gravatar Actually, importing modules *is* thread-safe, in that there is an interpreter lock preventing two modules from being imported at the same time. However, this trick still isn't thread-safe.

The DecoratorTools library (available from the CheeseShop) lets you do this in a thread-safe way: instead of subclassing a Statement class, you just define a function that calls 'decorate_class', passing in a class decorator function (takes a class, returns a class). Then your class decorator can do whatever it wants to to the class. This approach is threadsafe because it manipulates the class being built to create a decorator chain, instead of using a single global decorator chain.

(And of course, it isn't limited to creating statements for Elixir, and it isn't limited to a particular base class or metaclass. It'll work with literally any metaclass, or none at all.)


Name:

Email:

URL:

Comment:  ? 

 

Commenting by HaloScan