Questions tagged [filelock]

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

190 questions
1
vote
1 answer

Permission denied when trying to write a file with FileLock, Python

I'm trying to write a binary file and lock access for other processes until the file has fully written on the disk. I'm working on Windows OS. The interesting thing is that the code working OK if I write small files (~1KB), but when I'm trying to…
1
vote
0 answers

Process cannot access the file beacause another process has locked a portion, while using java.nio.channels.FileLock

When I'm running the following portion of code in Windows (in Linux I don't get this type of error), I get the java.io.IOException in the title. How can I resolve this issue? Thanks RandomAccessFile randomAccessFile = null; try { …
1
vote
1 answer

Django send_mail "lock already in place. quitting."

I am having an issue with send_mail in Django. It has been working fine until I tried to change some Email settings to have it use an EMAIL_HOST_USER and EMAIL_HOST_PASSWORD. When I did that my test emails where not sent. I reverted back to my old…
Cyrus Cold
  • 269
  • 2
  • 11
1
vote
1 answer

Java NIO FileLock allows other process to write to a locked file

I'm acquiring a lock on a file in one Java application with the following code: ... File file = new File("/some/file/at/some/path.txt"); FileChannel channel = new RandomAccessFile(file, "rw").getChannel(); FileLock lock = channel.tryLock(); if…
Dilip Raj Baral
  • 3,060
  • 6
  • 34
  • 62
1
vote
1 answer

PermissionError [Errno 13] when writing to a file after using lockfile in python

I would like to safely open and write to a file, so I decided to use the fileLock python library. This is my code: with filelock.FileLock('../rsc/datasets/train/' + server_predict.remove_special_chars(str(id_park)) + '.csv'): …
1
vote
2 answers

db2 import export to same ixf but different processes

Does db2 check for file locks when running the db2 import/export command? I have 2 processes, one runs an export to ixf, and another process that imports the ixf. Both run multiple times a day, the export process is variable time and I don't want…
linuxnovice
  • 55
  • 1
  • 3
1
vote
0 answers

Log.txt file locked, gets too large

I'm running NiceHash's latest version, there's a dialog that's saved to a log.txt file. It gets large enough to crash windows, if not stopped, so I wrote a batch file with the following: forfiles -p C:\Users\CBRocks\AppData\Roaming\nhm2\logs /m log*…
CBRocks
  • 11
  • 2
1
vote
1 answer

Opening an XPS file using package keeps file locked

The following C# code keeps the file locked, so DeleteFile fails: String srcFile = @"D:\I\deleteme\TempFiles\Mem\XPS\1.xps"; Package package = Package.Open(srcFile, FileMode.Open, FileAccess.Read, FileShare.Read); XpsDocument xpsDoc = new…
Cristi Br
  • 11
  • 2
1
vote
0 answers

Does CIFS byte range locking work across multiple Linux client nodes with Windows as the server?

Trying to let multiple processes across different Linux nodes write to a shared CSV file on a Windows shared folder. I tested if it works by launching 2 processes on separate nodes, each appending 10k lines to a file. Then I check if the line count…
Yale Zhang
  • 1,447
  • 12
  • 30
1
vote
0 answers

FileLock throws EAGAIN exception when call FileLock::tryLock() method

I'm developing a multiprocess solution with Android SyncAdapter and Domain Driven Design (DDD) comcepts. Just after login It's necessary to download some data to continue. Then I start the SyncAdapter manually and (the intention) await ultil it…
1
vote
1 answer

How to lock file for another threads

This is my method that compresses file into archive: public void addFilesToArchive(File source, File destination) throws IOException, ArchiveException { try (FileOutputStream archiveStream = new FileOutputStream(destination); …
Pero Kulić
  • 31
  • 1
  • 5
1
vote
1 answer

Locking an XLSX file for reading and writing with FileInputStream, FileOutputStream, and RandomAccessFile

I have an excel that I want to be locked when each forked process is reading and writing to it. Apache poi requires me to use FileInputStream and FileOutputStream for reading and writing to that file, but all the examples I've seen for locking a…
aoatley
  • 13
  • 3
1
vote
1 answer

PDFBox locks JPEG input file until application exits

I'm using PDFBox RC2 in a Windows 7 environment, Java 1.8_66. I'm using it to create a PDF from a collection of 200dpi page-sized image files, both JPEG and PNG. It turns out that when adding JPEG files to a PDF, the PDImageXObject.createFromFile()…
Ketchup201
  • 129
  • 1
  • 9
1
vote
3 answers

How safe is it to use Java FileLock?

How safe is it to use java.nio.channels.FileLock for locking files among processes? It is stated that other processes can not access the file if we have an exclusive lock. However, the below answer on another SO question states other processes have…
Guillotine1789
  • 342
  • 4
  • 12
1
vote
2 answers

Windows Java File lock when referencing existing file in constructor?

Suppose I do the following in java for a process that stays open: import java.io.File; import java.util.Date; public class LogHolder { public static void main(String[] args) { File file1 = new File("myLogFile.log"); while…
hawkeye
  • 34,745
  • 30
  • 150
  • 304