import os
# very simple mutex implementation using atomic file operations
# does not keep track of owner of the mutex only if it is locked or not
class FileLock:
    def lock(self, name):
        try:
            os.open(name+'.lock', os.O_CREAT | os.O_EXCL)
            return True
        except FileExistsError:
            return False
    def unlock(self, name):
        os.remove(name+'.lock')

401989fbe1e539ba9f6809f031bd444058c89064
<mask token>


class FileLock:
    <mask token>
    <mask token>

<mask token>


class FileLock:
    <mask token>

    def unlock(self, name):
        os.remove(name + '.lock')

<mask token>


class FileLock:

    def lock(self, name):
        try:
            os.open(name + '.lock', os.O_CREAT | os.O_EXCL)
            return True
        except FileExistsError:
            return False

    def unlock(self, name):
        os.remove(name + '.lock')

import os


class FileLock:

    def lock(self, name):
        try:
            os.open(name + '.lock', os.O_CREAT | os.O_EXCL)
            return True
        except FileExistsError:
            return False

    def unlock(self, name):
        os.remove(name + '.lock')

import os
# very simple mutex implementation using atomic file operations
# does not keep track of owner of the mutex only if it is locked or not
class FileLock:
    def lock(self, name):
        try:
            os.open(name+'.lock', os.O_CREAT | os.O_EXCL)
            return True
        except FileExistsError:
            return False
    def unlock(self, name):
        os.remove(name+'.lock')
