Re: [f2py] Re: unloading/reloading compiled modules
Pearu Peterson <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Demaeyer Jonathan wrote:
> Pearu Peterson a écrit :
>> Hi,
>
> ...
>> Another way would be
>> to have a master process that calls python as a separate subprocess that
>> carries out computations with f2py generated extension modules. If the
>> extension module is changed then the next subprocess picks up the
>> updated extension module.
>>
> ...
>> HTH,
>> Pearu
>
> Hi,
>
> I would like to try this.
> But I wonder if importing a module inside a Thread object of the python
> threading module means that the import is only available in the
> subprocess or also in the main process?
No, that is not working:
>>> from numpy.f2py import compile as fcomp
>>> from scipy.misc.pexec import ParallelExec
>>> def mkfoo(i):
... fcomp(' subroutine foo\n print*, %s\n end' % i,
'foo', verbose=0)
... import foo
... foo.foo()
...
...
>>> pe = ParallelExec()
>>> pe('mkfoo(3)')
3
>>> pe('mkfoo(5)')
3
Here `5` instead of `3` would be a desired output.
What I meant was that the subprocess is a new python
process that is executed via, say, subprocess.Popen.
For example, the main process is generating extension modules
that are imported and used by some other module that is
used within Popen process.
Pearu