[mod_python] Threading and apache.import_module

Nicolas Lehuen nicolas.lehuen at gmail.com
Sat Jun 18 02:47:17 EDT 2005


Hi Dan,

The subversion repository already contains fixes to the
apache.import_module function so that it is thread-safe. You can check
it out to see how it is done.

Regards,

Nicolas

2005/6/17, Dan Eloff <dan.eloff at gmail.com>:
> Well this is the biggest problem in my otherwise threadsafe code. From
> what I've read, importing/reloading modules in a threaded environment
> is just plain dangerous. There could be any number of requests
> executing code from and accessing global variables in a module when it
> changes and gets reloaded. Then you have the two level problem of what
> happens to the executing requests, as well as what happens when
> multiple incoming requests all spot that the module has changed, and
> reload it multiple times in quick succession, re-executing code in the
> module scope (this is pretty much worst case)
> 
> I know Graham knows a lot more about this than I do (help!).
> 
> I do have a lot of flexibility here, since I'm using my own publisher
> I do not have to use apache.import_module. In fact I would prefer to
> not have the whole importing/reloading business affect my code outside
> of the publisher, that way I can change things internally at will.
> Clearly one option is to create a simple import function that imports
> once only in a production environment, and every time in a development
> env, but I'm still interested in exploring the options.
> 
> -Dan
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



More information about the Mod_python mailing list