atom feed3 messages in net.sourceforge.lists.courier-users[courier-users] Loading / reloading P...
FromSent OnAttachments
Alessandro VeselyJun 7, 2017 4:32 am.txt
Gordon MessmerJun 7, 2017 12:39 pm 
Alessandro VeselyJun 8, 2017 2:52 am 
Subject:[courier-users] Loading / reloading Pythonfilter
From:Alessandro Vesely (ves@tana.it)
Date:Jun 7, 2017 4:32:13 am
List:net.sourceforge.lists.courier-users
Attachments:

I changed the code of a filter which is already configured and running. Now I have to install it. Last time I issued courierfilter stop, and then start. However, that way I have to reload also clamav databases, which takes a long time. Is there any better way to upgrade the running Python process?

BTW, in order to tell distributed filter from home-brewed ones, I install sym links in the dist-package/pythonfilter directory, which point to the source file. I note that Python does not produce any .pyc in that case. However, the following command compiles in the current directory irrespectively of whatever:

python -m compileall -l attachments.py

Since the pyc is what should get loaded when loading a module, an idea could be to reload modules if they have been recompiled since the last time they were loaded. Let me attach the idea. Beware: I did'n run it, not even once, and didn't fully understand the caveats about using reload(), see e.g.:

https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module#answer-438845

One more question, about virtualenv. Has anyone had experience loading Pythonfilter that way under Courier? Another possibility is to install Pythonfilter globally, but keep additional packages in a virtualenv, just to ease tracking requirements.

TIA Ale

------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot