AWS Thinkbox Discussion Forums

the process cannot access this file

Hi there,

There was an issue i noted a while back:
viewtopic.php?f=86&t=10459

This appears to be specific to .Net file access functions for some reason. We customized the 3dsmax.py to also feed the contents of the vraylog.txt file to the max logs, and had the exact same permissions issue:

The process cannot access the file ‘c:\VRayLog.txt’ because it is being used by another process.

But switching to regular python reads could read the file just fine:

This fails: reader = File.OpenText( sVrayLogFile )
This also fails: sVrayLog = File.ReadAllText( sVrayLogFile )

This works just fine: sFile = open( sVrayLogFile, ‘rt’ )

Not sure why that is, but maybe it would be beneficial to fix the regular max network log reader to use python reads as well.

cheers
laszlo

Hey Laszlo,

Try replacing these blocks of code

                reader = File.OpenText( self.NetworkLogFile )
                reader.BaseStream.Seek( max( self.NetworkLogFileSize - 192, 0 ), SeekOrigin.Begin )
                self.NetworkLogFilePostfix = reader.ReadToEnd()
                reader.Close()
                        reader = File.OpenText( self.NetworkLogFile )
                        if( self.NetworkLogFileSize >= 0 ):
                            reader.BaseStream.Seek( max( self.NetworkLogFileSize - 2048, 0 ), SeekOrigin.Begin )
                        networkLog = reader.ReadToEnd()
                        reader.Close()

With these blocks (respectively):

                stream = FileStream( self.NetworkLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite )
                reader = StreamReader( stream )
                reader.BaseStream.Seek( max( self.NetworkLogFileSize - 192, 0 ), SeekOrigin.Begin )
                self.NetworkLogFilePostfix = reader.ReadToEnd()
                reader.Close()
                stream.Close()
                        stream = FileStream( self.NetworkLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite )
                        reader = StreamReader( stream )
                        if( self.NetworkLogFileSize >= 0 ):
                            reader.BaseStream.Seek( max( self.NetworkLogFileSize - 2048, 0 ), SeekOrigin.Begin )
                        networkLog = reader.ReadToEnd()
                        reader.Close()
                        stream.Close()

I double checked how File.OpenText works, and it turns out it only uses FileShare.Read, and not FileShare.ReadWrite. Let me know if this helps, and we can make these changes on our end.

Cheers,
Ryan

Hey Ryan,

This does the trick!

thanks,
Laszlo

With this change, maybe the retry 5 times functionality becomes redundant?

Glad to hear it worked! We’ll make this change in 7.2.

We’ll probably just keep the retries for now, in case some other temporary issue prevents us from accessing the file.

Cheers,
Ryan

Privacy | Site terms | Cookie preferences