encode / uvicorn

An ASGI web server, for Python. 🦄
https://www.uvicorn.org/
BSD 3-Clause "New" or "Revised" License
8.46k stars 733 forks source link

need help :uvicorn can't reload when user fastapi and apscheduler #588

Closed fenghaoyu closed 4 years ago

fenghaoyu commented 4 years ago

when i user fastapi and apscheduler, uvicorn cant reload on linux centos. but it can work on windows. here is the code: file: main.py

def apscheduler():
    scheduler = AsyncIOScheduler()
    scheduler.add_job(my_jobs.tick, 'cron', hour=2, minute=0)
    deadline = datetime.datetime.now().replace(microsecond=0) + datetime.timedelta(seconds=5)
    scheduler.add_job(my_jobs.tick, 'date', run_date=deadline)

    try:
        scheduler.start()
    except Exception as e:
        scheduler.shutdown()

    return scheduler

apscheduler()
app = get_app()

script: uvicorn main:app --reload

tomchristie commented 4 years ago

Hiya - I'd love to be able to help directly, but I think we need to start directing usage questions, and anything that's not a clearly isolated issue towards the discussion group instead... https://gitter.im/encode/community

StackOverflow might also be worth a try.