ネットワーク共有を介して同じ CSV ファイルを読み書きするスクリプトをいくつか実行しています。
断続的にOSError: [Errno 2] No such file or directory: 'filename.csv'
(1 ~ 2 分ごと、書き込み/読み取りは 10 ~ 30 秒ごと)、ほとんどの場合、ファイルの書き込み/読み取りは正常に機能します。
どのスクリプトがいつファイルを開いているかを追跡し、エラーの詳細を取得する方法はありますか? つまり、ファイルは使用中ですか?ファイルサーバーへの接続が失われていますか?
プロセス モニターの使用:
通常の操作 (エラー メッセージなし):
2:33:52.4823608 PM python.exe 2668 IRP_MJ_QUERY_VOLUME_INFORMATION filename.csv SUCCESS Type: QueryDeviceInformationVolume, DeviceType: Disk, Characteristics: Remote
2:33:52.4823848 PM python.exe 2668 IRP_MJ_QUERY_VOLUME_INFORMATION filename.csv SUCCESS Type: QueryDeviceInformationVolume, DeviceType: Disk, Characteristics: Remote
2:33:52.4824062 PM python.exe 2668 IRP_MJ_QUERY_VOLUME_INFORMATION filename.csv BUFFER OVERFLOW Type: QueryInformationVolume, VolumeCreationTime: 1/1/1601 8:00:00 AM, VolumeSerialNumber: D020-FD78, SupportsObjects: False, VolumeLabel: DAT`
2:33:52.4827061 PM python.exe 2668 IRP_MJ_QUERY_INFORMATION filename.csv BUFFER OVERFLOW Type: QueryAllInformationFile, CreationTime: 4/24/2012 2:36:07 PM, LastAccessTime: 4/24/2012 2:36:07 PM, LastWriteTime: 4/24/2012 2:36:07 PM, ChangeTime: 4/24/2012 2:36:07 PM, FileAttributes: A, AllocationSize: 1,048,576, EndOfFile: 118,342, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x45060de, EaSize: 0, Access: None, Position: 0, Mode: , AlignmentRequirement: Byte
2:33:52.4837725 PM python.exe 2668 FASTIO_QUERY_INFORMATION filename.csv FAST IO DISALLOWED Type: QueryStandardInformationFile
2:33:52.4837820 PM python.exe 2668 IRP_MJ_QUERY_INFORMATION filename.csv SUCCESS Type: QueryStandardInformationFile, AllocationSize: 1,048,576, EndOfFile: 118,342, NumberOfLinks: 1, DeletePending: False, Directory: False
2:33:52.4841324 PM python.exe 2668 FASTIO_QUERY_INFORMATION filename.csv FAST IO DISALLOWED Type: QueryStandardInformationFile
2:33:52.4841458 PM python.exe 2668 IRP_MJ_QUERY_INFORMATION filename.csv SUCCESS Type: QueryStandardInformationFile, AllocationSize: 1,048,576, EndOfFile: 118,342, NumberOfLinks: 1, DeletePending: False, Directory: False
2:33:52.4844948 PM python.exe 2668 IRP_MJ_READ filename.csv SUCCESS Offset: 117,318, Length: 1,024
2:33:52.4857179 PM python.exe 2668 IRP_MJ_READ filename.csv END OF FILE Offset: 118,342, Length: 4,096
2:33:52.4862472 PM python.exe 2668 FASTIO_QUERY_INFORMATION filename.csv FAST IO DISALLOWED Type: QueryStandardInformationFile
2:33:52.4862564 PM python.exe 2668 IRP_MJ_QUERY_INFORMATION filename.csv SUCCESS Type: QueryStandardInformationFile, AllocationSize: 1,048,576, EndOfFile: 118,342, NumberOfLinks: 1, DeletePending: False, Directory: False
2:33:52.4867251 PM python.exe 2668 IRP_MJ_READ filename.csv SUCCESS Offset: 116,294, Length: 1,024
2:33:52.4873473 PM python.exe 2668 IRP_MJ_READ filename.csv SUCCESS Offset: 117,318, Length: 512
2:33:52.4878825 PM python.exe 2668 FASTIO_QUERY_INFORMATION filename.csv FAST IO DISALLOWED Type: QueryStandardInformationFile
2:33:52.4878917 PM python.exe 2668 IRP_MJ_QUERY_INFORMATION filename.csv SUCCESS Type: QueryStandardInformationFile, AllocationSize: 1,048,576, EndOfFile: 118,342, NumberOfLinks: 1, DeletePending: False, Directory: False
2:33:52.4882153 PM python.exe 2668 IRP_MJ_READ filename.csv SUCCESS Offset: 115,270, Length: 1,024
2:33:52.4889601 PM python.exe 2668 IRP_MJ_READ filename.csv SUCCESS Offset: 116,294, Length: 512
2:33:52.4895164 PM python.exe 2668 IRP_MJ_CLEANUP filename.csv SUCCESS
2:33:52.4895513 PM python.exe 2668 IRP_MJ_CLOSE filename.csv SUCCESS
別のプログラムで開いているファイル (Errno 13 - 許可が拒否されました):
1:12:42.0840918 PM python.exe 5772 IRP_MJ_CREATE filename.csv SHARING VIOLATION Desired Access: Generic Write, Read Attributes, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
その他のエラー(これが Python エラーに対応するかどうかは不明)
2:57:59.9371101 PM python.exe 3584 IRP_MJ_CREATE filename.log BAD NETWORK PATH Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
これは OSError 2 として表示されますか?