{"id":28389,"library":"timeloop","title":"Timeloop","description":"A simple library for scheduling periodic tasks using decorators. Current version: 1.0.2. Low release cadence; last update in 2021.","status":"maintenance","version":"1.0.2","language":"python","source_language":"en","source_url":"https://github.com/sankalpjonn/timeloop","tags":["scheduling","periodic-tasks","cron","decorators"],"install":[{"cmd":"pip install timeloop","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"Correct import for the main scheduler class.","symbol":"Timeloop","correct":"from timeloop import Timeloop"}],"quickstart":{"code":"from timeloop import Timeloop\nfrom datetime import timedelta\n\ntl = Timeloop()\n\n@tl.job(interval=timedelta(seconds=5))\ndef job1():\n    print(\"5 seconds job\")\n\nif __name__ == '__main__':\n    tl.start(block=True)","lang":"python","description":"Basic usage: create a Timeloop instance, decorate a function with @tl.job, and start the loop."},"warnings":[{"fix":"Use tl.start(block=False) and keep the main thread alive manually, or run in a separate thread.","message":"Using tl.start(block=True) will block the main thread. If used in a script without a background thread, the program will hang until interrupted.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider alternatives like `schedule`, `apscheduler`, or use a fork with fixes.","message":"The library has not been updated since 2021; it uses the deprecated `utcnow()` internally and may break in future Python versions (Python 3.12 deprecated `datetime.utcnow()`).","severity":"deprecated","affected_versions":">=1.0.2"},{"fix":"Wrap job body in try/except or use a custom error handler via `tl._handle_exception`.","message":"The `@tl.job` decorator does not capture exceptions; if a job raises an exception, the scheduler stops without warning.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from timeloop import Timeloop`.","cause":"Importing incorrectly (e.g., `import timeloop` then `timeloop.Timeloop` works, but `from timeloop import timeloop` is wrong).","error":"AttributeError: module 'timeloop' has no attribute 'Timeloop'"},{"fix":"Instantiate with `tl = Timeloop()`.","cause":"Attempting to call the Timeloop class as a function (e.g., `tl = Timeloop()` is correct; `tl = Timeloop` missing parentheses is wrong).","error":"TypeError: 'Timeloop' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}