{"id":9358,"library":"tgscheduler","title":"TGScheduler","description":"TGScheduler is a pure Python scheduler library, currently at version 1.7.0. It enables applications to run one-time or recurring tasks, supporting execution in-process (using threads), as forked processes, or synchronously within the main code. The library is based on the scheduler originally built into TurboGears 1, offering a straightforward approach to task automation. Its release cadence is infrequent, with the last update in 2015.","status":"maintenance","version":"1.7.0","language":"python","source_language":"en","source_url":"https://pypi.org/project/tgscheduler/","tags":["scheduler","task-scheduling","pure-python","utility"],"install":[{"cmd":"pip install tgscheduler","lang":"bash","label":"Install TGScheduler"}],"dependencies":[],"imports":[{"wrong":"from tgscheduler import Scheduler","symbol":"scheduler","correct":"from tgscheduler import scheduler"},{"symbol":"add_cron_like_task","correct":"from tgscheduler import add_cron_like_task"},{"symbol":"start_scheduler","correct":"from tgscheduler import start_scheduler"}],"quickstart":{"code":"from tgscheduler import Scheduler\nimport time\nimport logging\n\nlogging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')\n\ndef my_task(message):\n    logging.info(f\"Executing task with message: {message}\")\n\ns = Scheduler()\n\n# Schedule a task to run once, 5 seconds from now\ns.add_task(my_task, args=('One-time task!',), delay=5)\n\n# Schedule a recurring task every 10 seconds\ns.add_task(my_task, args=('Recurring task!',), interval=10, initialdelay=2, name='RecurringExample')\n\nlogging.info(\"Scheduler started. Tasks will run.\")\ntry:\n    # Run the scheduler in a blocking loop (or integrate into an existing event loop)\n    while True:\n        s.tick()\n        time.sleep(1) # Sleep to prevent busy-waiting\nexcept KeyboardInterrupt:\n    logging.info(\"Scheduler stopped by user.\")\n    s.shutdown()","lang":"python","description":"This quickstart demonstrates how to initialize the TGScheduler, add both one-time and recurring tasks, and run the scheduler in a simple blocking loop. Tasks are defined as callable functions, and arguments can be passed via the `args` parameter. The `delay` argument schedules a task for a single future execution, while `interval` schedules it for recurring executions. Logging is included to show task execution."},"warnings":[{"fix":"Run `s.tick()` in a separate thread or use an asynchronous loop that yields control, calling `s.tick()` at appropriate intervals.","message":"TGScheduler is a blocking scheduler if `tick()` is called in a tight loop. To integrate it into existing asynchronous applications (e.g., web servers), ensure `tick()` is called periodically without blocking the main event loop, or run the scheduler in a separate thread.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For new projects or those requiring active development/support, evaluate modern alternatives like APScheduler or schedule. If using TGScheduler, thoroughly test on your target Python version.","message":"The project appears to be in maintenance mode, with the last PyPI release in 2015. While functional, it might not receive updates for new Python versions or critical bug fixes. Consider more actively maintained alternatives for new projects requiring robust scheduling.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Always provide `args` as a tuple, e.g., `s.add_task(my_func, args=('arg1', 'arg2',))` or `s.add_task(my_func, args=('single_arg',))`.","message":"TGScheduler's `add_task` method requires careful handling of task arguments. If a task function takes arguments, they must be passed as a tuple to the `args` parameter, even for a single argument.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1':51 '1.7.0':12 '2015':69 'applic':15 'approach':55 'autom':58 'base':43 'built':48 'cadenc':61 'code':39 'current':9 'enabl':14 'execut':25 'fork':32 'in-process':26 'infrequ':63 'last':66 'librari':8,41 'main':38 'offer':52 'one':19 'one-tim':18 'origin':47 'process':28,33 'pure':5,75 'pure-python':74 'python':6,76 'recur':22 'releas':60 'run':17 'schedul':7,46,70,73 'straightforward':54 'support':24 'synchron':35 'task':23,57,72 'task-schedul':71 'tgschedul':1,2 'thread':30 'time':20 'turbogear':50 'updat':67 'use':29 'util':77 'version':11 'within':36","created_at":"2026-04-16T18:49:48.498463+00:00","updated_at":"2026-04-16T18:49:48.498463+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.7.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://bitbucket.org/xcg/tgscheduler","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/tgscheduler/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["workflow"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}