Thanks for trying this out Justin. I’ll address this one first in case it
affects your interest in the other answers.
All this academic stuff aside, are you pretty confident that your
bottleneck is disk IO on the scene file?
No, it certainly isn’t the bottleneck, I though that much was clear from
the first tests I posted in which exporting was many times faster, even
*with* writing to disk. This is out of plain curiosity only.
So what Maya does is it moves the given path to a temp name if it already
exists, then writes the new scene to your given path, and if all succeeds,
it removes the previously existing one.
Would it be possible that it does things differently, when writing to a
non-existing file? In my case, it’s safe to assume the path will always be
different and non-existing. Or were you referring to the fact that an mmap
file must be written to disk before being manipulated?
Here’s my limited understanding.
import mmapimport contextlib
cmds.file(rename="temp.ma") # Does not exist
path = cmds.file(sceneName=True, q=True)
# This has to happen, which makes it exist, which may cause the
behaviour you described.with open(path, "wb") as f:
f.write("empty")
with open(path, "r+b") as f:
with contextlib.closing(mmap.mmap(f.fileno(), 0)) as mm:
cmds.file(exportAll=True, force=True)
In which case, cmds.file is attempting to open a *new* file handle via the
path given; but it won’t work (obviously), and I’m getting a “Can’t write
to …” error.
I also had a look at an example file translator, and it looks like this is
it’s given arguments.
def writer(self, fileObject, optionString, accessMode):
Reference <http://stackoverflow.com/questions/26585667/api-exporting-issue>
In which case fileObject is a MFileObject from which a fullName() is taken
and given to a Python open() command. If that’s the case, then you couldn’t
give it a file-handle directly which makes mmap possibly impossible (?)
without writing a translator yourself and making one in there.
On my linux box, by default, I have “/dev/shm” which is the shared memory
tmpfs device.
That could work; the solution can be studio-specific and doesn’t need to be
cross-platform. The question then is whether it’s simpler to write your own
translator, or setup and work with a tempfs device.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODoaYPfPBWdpuS_weNnD3cPy-rCtac0K28scAJN4YDivA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.