Skip to content

Conversation

@Ivansete-status
Copy link
Contributor

@Ivansete-status Ivansete-status commented Dec 23, 2025

Description

  • This is meant to avoid leaking file descriptors when using Nim libraries.
  • Currently, nim-chronos global dispatcher delegates the de-allocation of certain resources to the OS, when an app ends.
  • Nim libraries leverage nim-chronos threads, i.e., a Nim library component starts a nim-chronos thread to operate with.
  • Certain use cases, e.g. tests, require start/stop Nim library component, which implies start/stop nim-chronos threads.
  • Then, certain file descriptors are leaked upon consecutive Nim-library-component creation/destruction (nim-chronos thread start/stop.) For example, on unix-like systems, fds handled by selector are leaked.

Changes

  • Attend and complete in-flight work requests to the chronos thread.
  • nim-chronos thread blocks further tasks when shutdown is in progress.
  • Free all resources, on each platform, when all tasks are completed.

Context

The issue has been detected while testing nim-sds in status-go

This status-go PR contains better issue detail.
This temporary workaround was implemented.

@Ivansete-status Ivansete-status self-assigned this Dec 23, 2025
@Ivansete-status Ivansete-status marked this pull request as draft December 23, 2025 13:58
@Ivansete-status Ivansete-status changed the title allow close selector in asyncengine allow graceful shutdown in asyncengine Jan 5, 2026
@Ivansete-status Ivansete-status deleted the add-rm-selector branch January 6, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant