Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Pre-alpha Breaking changes are expected. Verify Agencia Estatal de Administración Tributaria (AEAT) deadlines before filing. Updates Latest download Report an issue
CADRUMO docs
Getting started CLI reference How it works API
EN
  • English
  • Español
  • Català
  • Magyar
Cadrumo documentation - local Spanish tax preparation
  • Getting started
  • Get Cadrumo
  • Install Cadrumo
  • Quickstart
  • Connect an agent (MCP)
  • First quarterly filing
  • The income-tax year
  • The IVA year

Your profile

  • Set up a profile
  • Authenticate with AEAT
  • Maintain census facts
  • Which modelos apply to you
  • Protect data access

Your calendar

  • Filing calendar
  • AEAT notifications
  • Filing readiness

Your ledger

  • Work with transactions
  • Classify transactions
  • Classify with an LLM
  • Attach invoices and receipts
  • Manage business invoices
  • Correct mistakes
  • IVA prorrata deductions

Your filings

  • The filing workflow
  • Modelo 036 (censo)
  • Modelo 100 (Renta)
  • Modelo 130 (IRPF instalment)
  • Modelo 303 (IVA)
  • Modelo 349 (intra-community)
  • Modelo 390 (IVA summary)
  • Calculation inputs
  • Google Sheets review
  • Verify a filing
  • File at AEAT
  • Reconcile a filing

Help

  • Troubleshooting
  • Publish runtime authority
  • Disclaimer

Reference

  • CLI reference
  • Cadrumo reference
  • Glossary
  • Casilla reference
  • Legal reference

How it works

  • Overview

Project

  • Updates and downloads
  • Architecture
  • Authoring guide
  • API
    • cadrumo package
      • cadrumo.adapters package
      • cadrumo.application package
      • cadrumo.core package
        • cadrumo.core.access_gate package
        • cadrumo.core.classification package
        • cadrumo.core.corpus_manifest package
        • cadrumo.core.decimal package
        • cadrumo.core.errors package
        • cadrumo.core.i18n package
        • cadrumo.core.identity package
        • cadrumo.core.money package
        • cadrumo.core.observability package
        • cadrumo.core.parsing package
        • cadrumo.core.redaction package
        • cadrumo.core.resources package
        • cadrumo.core.telemetry package
        • cadrumo.core.time package
        • cadrumo.core._config_runtime module
        • cadrumo.core._config_validation module
        • cadrumo.core.action_argument_resolution module
        • cadrumo.core.aeat_csv module
        • cadrumo.core.aggregation module
        • cadrumo.core.amendment_kind_regime module
        • cadrumo.core.async_cleanup module
        • cadrumo.core.atomic_write module
        • cadrumo.core.auth_provider module
        • cadrumo.core.auth_session_keys module
        • cadrumo.core.authority_grade module
        • cadrumo.core.base64_codec module
        • cadrumo.core.bucket_pointer module
        • cadrumo.core.calendar_shift module
        • cadrumo.core.capabilities module
        • cadrumo.core.casilla_id module
        • cadrumo.core.casilla_value_kind module
        • cadrumo.core.citation_grounding module
        • cadrumo.core.classifier_input_source module
        • cadrumo.core.cli_metadata module
        • cadrumo.core.click_context module
        • cadrumo.core.concept_lifecycle module
        • cadrumo.core.concepto_ingreso module
        • cadrumo.core.config module
        • cadrumo.core.config_integration_fields module
        • cadrumo.core.config_live_tests module
        • cadrumo.core.config_llm_fields module
        • cadrumo.core.config_runtime_fields module
        • cadrumo.core.config_state_root module
        • cadrumo.core.config_storage_route module
        • cadrumo.core.config_support module
        • cadrumo.core.config_timeouts module
        • cadrumo.core.confirmation_gate module
        • cadrumo.core.corpus_text module
        • cadrumo.core.country_code module
        • cadrumo.core.credentials module
        • cadrumo.core.declaracion_idioma module
        • cadrumo.core.descendant_relacion module
        • cadrumo.core.directory_scan module
        • cadrumo.core.document_shape module
        • cadrumo.core.draft_discrepancy module
        • cadrumo.core.ed25519_signing module
        • cadrumo.core.estado_casilla_oficial module
        • cadrumo.core.export_exemption_reason module
        • cadrumo.core.export_layout_format module
        • cadrumo.core.external_constants module
        • cadrumo.core.field_grounding module
        • cadrumo.core.field_origin module
        • cadrumo.core.field_role module
        • cadrumo.core.file_change_time module
        • cadrumo.core.file_permissions module
        • cadrumo.core.filed_history_discovery_signal module
        • cadrumo.core.filing_producer_key module
        • cadrumo.core.filing_projection_ref module
        • cadrumo.core.filing_projection_ref_support module
        • cadrumo.core.filing_year module
        • cadrumo.core.flows module
        • cadrumo.core.foreign_asset_obligation module
        • cadrumo.core.frozen_mapping module
        • cadrumo.core.fsync module
        • cadrumo.core.fts_query module
        • cadrumo.core.google_credential_source module
        • cadrumo.core.hardware module
        • cadrumo.core.hashing module
        • cadrumo.core.hex module
        • cadrumo.core.iban module
        • cadrumo.core.identifier_grammar module
        • cadrumo.core.identity_check_verdict module
        • cadrumo.core.image_media_type module
        • cadrumo.core.invoice_link module
        • cadrumo.core.irnr module
        • cadrumo.core.iva_category_resolution module
        • cadrumo.core.iva_compensation_provenance module
        • cadrumo.core.iva_deduction_fact module
        • cadrumo.core.json_contract module
        • cadrumo.core.json_shapes module
        • cadrumo.core.ledger_sort module
        • cadrumo.core.link_safety module
        • cadrumo.core.lockfile_unlink module
        • cadrumo.core.locks module
        • cadrumo.core.locks_errors module
        • cadrumo.core.logging module
        • cadrumo.core.model_catalogue module
        • cadrumo.core.modelo module
        • cadrumo.core.modelo_232_codigos module
        • cadrumo.core.modelo_work_progress_state module
        • cadrumo.core.models module
        • cadrumo.core.notificacion_estado_servicio module
        • cadrumo.core.observed_header_fact module
        • cadrumo.core.operations module
        • cadrumo.core.operator_action_enums module
        • cadrumo.core.operator_progress module
        • cadrumo.core.optional_extras module
        • cadrumo.core.output_rendering module
        • cadrumo.core.package_version module
        • cadrumo.core.paths module
        • cadrumo.core.payment_election module
        • cadrumo.core.percentage module
        • cadrumo.core.period module
        • cadrumo.core.pid_liveness module
        • cadrumo.core.post_filing_event module
        • cadrumo.core.precondition_action_invariants module
        • cadrumo.core.presentation module
        • cadrumo.core.prior_domiciliation_election module
        • cadrumo.core.process_binding module
        • cadrumo.core.product_identity module
        • cadrumo.core.profile_discovery module
        • cadrumo.core.profile_publication module
        • cadrumo.core.profile_session module
        • cadrumo.core.prorrata_exclusions module
        • cadrumo.core.prorrata_register module
        • cadrumo.core.prose_elision module
        • cadrumo.core.provenance_stamp module
        • cadrumo.core.record_design_epoch module
        • cadrumo.core.refund_election module
        • cadrumo.core.register_scoping_signal module
        • cadrumo.core.registry_token module
        • cadrumo.core.remote_authority module
        • cadrumo.core.renta_declaracion_type module
        • cadrumo.core.requirement module
        • cadrumo.core.rescate_type module
        • cadrumo.core.result_disposition module
        • cadrumo.core.revision_review module
        • cadrumo.core.schema_family_disposition module
        • cadrumo.core.secure_object_write module
        • cadrumo.core.source_locator module
        • cadrumo.core.spanish_postcode module
        • cadrumo.core.spanish_stemming module
        • cadrumo.core.storage_materialization module
        • cadrumo.core.storage_taxonomy module
        • cadrumo.core.storage_taxonomy_locations module
        • cadrumo.core.sync_surface module
        • cadrumo.core.tabular module
        • cadrumo.core.tax_domain module
        • cadrumo.core.text_bounds module
        • cadrumo.core.text_fold module
        • cadrumo.core.tipos_actividad module
        • cadrumo.core.toml module
        • cadrumo.core.transport_locus module
        • cadrumo.core.tty module
        • cadrumo.core.type_adapters module
        • cadrumo.core.type_guards module
        • cadrumo.core.unit_proportion module
        • cadrumo.core.url_validation module
        • cadrumo.core.validity_window module
        • cadrumo.core.windows_contention module
        • cadrumo.core.workbook module
      • cadrumo.domain package
      • cadrumo.entrypoints package
Back to top
View this page
Edit this page
Home/Python API overview/cadrumo package/cadrumo.core package/cadrumo.core.lockfile_unlink module

cadrumo.core.lockfile_unlink module¶

Share-violation-tolerant lockfile removal shared by the crash-recoverable locks.

Every PID-stamped lockfile in this project is inspected by its waiters: a process that finds the lock taken opens the file to read the holder’s PID and decide whether the holder is still alive. On Windows the CRT opens that read without FILE_SHARE_DELETE, so for as long as the reader’s handle is open the holder’s unlink is refused with ERROR_SHARING_VIOLATION – surfaced by CPython as PermissionError with winerror == 32.

Left uncaught on a release path that is a wedge, not a delay: the lockfile survives stamped with a PID that is still a live process, so no peer will ever reclaim it as stale, and every later acquirer blocks to its own timeout. The subsystem the lock guards is unusable until the holder exits.

The window is small but not theoretical. Under cross-process contention on this project’s own bucket lock, three of four contending processes stranded their lockfile this way within a few seconds.

Two dispositions cover every call site, and which one applies is a property of the caller, not of the error:

  • Releasing a lock this process holds must retry to a deadline. Nobody else can clear it, so giving up strands the lock.

  • Reclaiming a lock judged stale, or a best-effort cleanup, must not retry and must not raise. Losing that race costs one more poll, and the next attempt reclaims it.

Both are unlink_lockfile() with different retry budgets, so the two lock subsystems and the locale catalogue guard cannot drift apart on the handling.

A blocked removal is never reported as a success. Windows cannot distinguish contention from a denying ACL at the unlink boundary, so the retry budget is what separates them: a transient block clears inside the window, and anything that outlasts it comes back as False for the caller to refuse on.

LOCKFILE_UNLINK_RETRY_SECONDS¶

Default budget for retrying a blocked release; a reader’s handle lives microseconds.

unlink_lockfile(path, *, retry_seconds=0.0, reason)[source]¶

Remove path, waiting out a peer’s open read handle if asked to.

Parameters:
  • path (Path) – The lockfile to remove. An already-absent file is a success.

  • retry_seconds (float) – How long to keep retrying while the removal is refused with a sharing violation. 0.0 (the default) makes a single best-effort attempt suitable for a stale reclaim.

  • reason (str) – Short call-site tag carried into the debug log.

Return type:

bool

Returns:

True when the lockfile is gone – removed here or already absent. False when a sharing violation outlasted retry_seconds; the caller decides whether that is a refusal or one more poll.

Raises:

OSError – For any removal failure Windows does not report as contention, and for every PermissionError off Windows, where no sharing-violation class exists to confuse it with.

Project notices

Cadrumo is pre-alpha, local-first software. It is not tax advice, is not affiliated with the Agencia Estatal de Administración Tributaria (AEAT), and never replaces official AEAT tools or advice from a qualified professional.

Stay current

  • Critical updates
  • Latest download
  • Release notes

Get help

  • Report an issue
  • CLI reference
  • How it works

Trust and responsibility

  • Disclaimer
  • Events and deadlines
  • Repository
Next
cadrumo.core.locks module
Previous
cadrumo.core.link_safety module
Copyright © 2026, the Cadrumo authors
Made with Sphinx and @pradyunsg's Furo
On this page
  • cadrumo.core.lockfile_unlink module
    • LOCKFILE_UNLINK_RETRY_SECONDS
    • unlink_lockfile()