Dag Sverre Seljebotn wrote:
> Dag Sverre Seljebotn wrote:
>> Dag Sverre Seljebotn wrote:
>>> Robert wrote:
>>>> Robert wrote:
>>>>> this and more related cleanup, speedup of importer, --inplace
>>>>> --verbose reload() .. here now:
>>>>>
>>>>> http://trac.cython.org/cython_trac/ticket/312
>>>>>
>>>> maybe sb likes to test it further:
>>>>
>>>> * support for dynamic "reload(<pyxmodule>)" added: e.g change of
>>>> the Cython code without stopping & relaunching a big app.
>>>> <so_path>.reloadNN files may arise, as previously loaded files are
>>>> blocked.
>>> This is great; I've always wanted reload to work...
>> Reloading a C module is a very unsafe thing. It basically requires
>> supporting PEP 3121 in Py3 and won't work in Py2 in most cases. You risk
>> all sorts of memory leaks and unexpected behaviour.
> 
> Yes, I remember trying to do this myself and reading some tickets about
> this not working in Py2...
> 
> Robert (not Bradshaw), can you perhaps submit the patch with the reload
> stuff taken out for now?

what is the time schedule?
a new one is there: 
http://trac.cython.org/cython_trac/attachment/ticket/312/
http://trac.cython.org/cython_trac/attachment/ticket/312/pyxi3.patch


did you with install(... reload_support=True) ? or without?

I just saw that on Linux you can (even without any 
Cython/pyximport) overwrite the .so,  then reload(themodule) and: 
Bus error or Segfault.

On Windows you cannot overwrite/remove/rename a loaded DLL file - 
and I (implicitly) relied on that - even when 
reload_support=False. The build,linking actually fails automatically.

I locked the reload in normal mode again completely as it was 
before and with reload_support=True it now goes always via fresh 
temporary .reloadXX files, not relying on the blockage.


> Idea:
> 
> Have pyximport "load" the module by generating a Python file and load it:
> 
> from pyxbuilds.foo_1 import *
> 
> Then when reloading this py-file, hook that, do a new compile and
> overwrite it with
> 
> from pyxbuilds.foo_2 import *
> 
> before Python reloads as usual. Could this work?
> 

this is what implicitely happens/happened here with 
reload_support=True , loading from another temporary file - so far 
on Windows. Yet he iterated just upon the write blockage. Yet low 
level via imp.load_dynamic (no restriction on the shape of filename).
( The thing with extra python file is 95%+ not necessary I guess. 
As its a low level DLL/filesystem thing, not about the name in 
sys.modules or so)

On Win there was no problem; used it all the time since I made it 
- with file in package trees too. I typically reload a 
continuously edited .pyx module up to some 20+ times into a 
running GUI app, and wonderful.

The memory usage of course will go up, DLL relocation going on 
etc... but its anyway just for dev/debugging.


I have no Cython setup currently on my Linux, but will go tomorrow 
see myself - but it shall work now.
With reload_support=False (default) at least, there is full stop 
again anyway. And the rest is for debugging anyway.


Robert











_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to