Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import tsinfer.threads as threads
import tsinfer.provenance as provenance
import tsinfer.exceptions as exceptions
import tsinfer.constants as constants
logger = logging.getLogger(__name__)
FORMAT_NAME_KEY = "format_name"
FORMAT_VERSION_KEY = "format_version"
FINALISED_KEY = "finalised"
# We use the zstd compressor because it allows for compression of buffers
# bigger than 2GB, which can occur in a larger instances.
DEFAULT_COMPRESSOR = numcodecs.Zstd()
# Lmdb on windows allocates the entire file size rather than
# growing dynamically (see https://github.com/mozilla/lmdb-rs/issues/40).
# For the default setting on windows, we therefore hard code a smaller
# map_size of 1GiB to avoid filling up disk space. On other platforms where
# sparse files are supported, we default to 1TiB.
DEFAULT_MAX_FILE_SIZE = 2 ** 30 if sys.platform == "win32" else 2 ** 40
def remove_lmdb_lockfile(lmdb_file):
lockfile = lmdb_file + "-lock"
if os.path.exists(lockfile):
os.unlink(lockfile)
class BufferedItemWriter(object):