On 5/8/21 10:16 PM, Jim J. Jewett wrote:
> Antoine Pitrou wrote:
>> On Sat, 8 May 2021 02:58:40 +0000
>> Neil Schemenauer nas-pyt...@arctrix.com wrote:
>>> It would be cool if we could mmap the pyc files and have the VM run
>>> code without an unmarshal step.
>>> What happens if another process mutates or truncates the file while the
>> CPython VM is executing code from the mapped file?  Crash?
> Why would this be any different than whatever happens now?  Just because it 
> is easier for another process to get (exclusive) access to the file if there 
> is a longer delay between loading the first part of the file and going back 
> for the docstrings and lnotab?
>
> -jJ

I think the issue being pointed out is that currently, when Python opens
the .pyc file for reading and keeps the file handle open, that will
block any other process from opening the file for writing, and thus
can't change the contents under it. Once it is all done, it can release
the lock as it won't need to read it again.

if it mapped the file into its address space, it would need a similar
sort of lock, but need to keep if for the FULL execution of the program,
so that no other process could change the contents behind its back. I
think normal mmapping doesn't do this, but if that sort of lock is
available, then it probably should be used.

-- 
Richard Damon

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QQHLCQC4UUWLM6HWHGOJ5SYCGBOO2LNS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to