mlco2 / mlco2/codecarbon

There appear to be 1 leaked semaphore objects to clean up at shutdown

Open
#720 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
323
Avg merge
1d 12h
Merged PRs (30d)
12

Description

  • CodeCarbon version: 2.8.0
  • Python version: 3.10.15
  • Operating System: Mac OS (Sequoia)
Description

We were using codecarbon 2.6.0 for fitbenchmarking and this was working fine.

We then updated to 2.7.1 and were seeing the"EmissionsTracker" object has no attribute '_scheduler' error.

Today, I updated the codecarbon dependency to test the latest version 2.8.0. Everything seems to work okay. But if I do a KeyboardInterrupt, I see the following warning:

UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

If I downgrade to codecarbon 2.6.0 and do a KeyboardInterrupt I do not see this warning. I see the normal stack trace of the KeyboardInterrupt.

Question: Has something been updated recently that might be causing this warning ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the KeyboardInterrupt with CodeCarbon 2.8.0 on Python 3.10.15 and macOS, then compare the behavior with 2.6.0 around EmissionsTracker shutdown. Trace the semaphore lifecycle and confirm that interrupting tracking no longer emits the leaked-semaphore warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.