You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a project.
Below are the files from which the problem resides.
cli.py :
importclickfromapscheduler.schedulers.backgroundimportBackgroundSchedulerscheduler=BackgroundScheduler(daemon=True)
deffunc():
print("scheduler running with interval....")
@click.command()@click.option('--interval', type=int, default=5, help='Interval for the scheduler in seconds')defstart_scheduler(interval):
scheduler.add_job(func, 'interval', seconds=interval)
scheduler.start()
try:
# Keep the script running (use Ctrl+C to stop it)whileTrue:
passexcept (KeyboardInterrupt, SystemExit):
scheduler.shutdown()
@click.command()defstop_scheduler():
ifscheduler.running:
scheduler.shutdown()
print("scheduler shut down")
else:
print("scheduler is not running")
@click.command()defstatus_scheduler():
ifscheduler.running:
print("Scheduler is running.")
else:
print("Scheduler is not running.")
setup.py :
""" This file is used for packaging the source code and command line interface"""fromsetuptoolsimportsetupsetup(
name='test_package',
version='0.1.0',
packages=['my_pack'],
install_requires=['click','APScheduler'],
entry_points={
'console_scripts': [
'start = my_pack.cli:start_scheduler''status = my_pack.cli:status_scheduler',
'stop = my_pack.cli:stop_scheduler',
],
},
)
Output i am getting :
when i run start command on terminal it's not running in the background.
to exit from the the script I have to hit ctr+C.
Expected output :
when i give start command it should return me shell to type another commands and should run in the background until it's stopped manually.
$ start
$
Troubleshooting Steps Taken
I've ensured that the scheduler is running in daemon mode by setting daemon=True.
I've explicitly called scheduler.start() after adding jobs.
I've checked the logs for any error messages related to the scheduler.
I've verified that the scheduler is running within the correct environment.
python version : Python 3.10.12
Platform : #40~22.04.1-Ubuntu
The text was updated successfully, but these errors were encountered:
ratnapalshende
changed the title
apscheduler not running as the background process
[Help Wanted] apscheduler not running as the background process
Feb 9, 2024
I am working on a project.
Below are the files from which the problem resides.
cli.py :
setup.py :
Output i am getting :
when i run
start
command on terminal it's not running in the background.to exit from the the script I have to hit
ctr+C
.Expected output :
when i give start command it should return me shell to type another commands and should run in the background until it's stopped manually.
Troubleshooting Steps Taken
daemon=True
.scheduler.start()
after adding jobs.Additional Context
python version : Python 3.10.12
Platform : #40~22.04.1-Ubuntu
The text was updated successfully, but these errors were encountered: