Skip to content

fix(cron): close lock_fd on failed flock to prevent fd leak#296

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
alireza78a:fix/fd-leak-in-scheduler-tick
Mar 6, 2026
Merged

fix(cron): close lock_fd on failed flock to prevent fd leak#296
teknium1 merged 1 commit intoNousResearch:mainfrom
alireza78a:fix/fd-leak-in-scheduler-tick

Conversation

@alireza78a
Copy link
Copy Markdown
Contributor

tick() opens lock_fd before the try block, so if fcntl.flock() raises BlockingIOError, the except clause returns without closing it. In a long-running gateway process where concurrent tick attempts are normal, this leaks a file descriptor on every skipped tick.

Fix: initialize lock_fd = None before the try block and close it in the except clause if it was opened.

@teknium1 teknium1 merged commit fec8a0d into NousResearch:main Mar 6, 2026
@teknium1
Copy link
Copy Markdown
Contributor

teknium1 commented Mar 6, 2026

Merged in fec8a0d 🎉

Clean catch — in a long-running gateway ticking every minute, this would leak one fd per concurrent tick attempt. Thanks @alireza78a!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants