Closed pangxiaobin closed 6 months ago
The ASGI 'lifespan' protocol appears unsupported.
error actually masks some exception. It's worth noting that APScheduler 4 requires AnyIO 4 which does not work yet with FastAPI.
That said, I tried with the latest master version and it seems to work fine. Could you try again with the latest alpha release?
The
ASGI 'lifespan' protocol appears unsupported.
error actually masks some exception. It's worth noting that APScheduler 4 requires AnyIO 4 which does not work yet with FastAPI.That said, I tried with the latest master version and it seems to work fine. Could you try again with the latest alpha release?
Thank you for your response. I have conducted some tests and have determined that the issue lies in the conflict of creating database tables. Upon reviewing your source code, I have found that setting the following parameter should resolve the error that occurs upon subsequent runs:
engine = create_async_engine("postgresql+asyncpg://postgres:password@localhost/testdb")
data_store = SQLAlchemyDataStore(engine)
data_store.start_from_scratch = True
The
ASGI 'lifespan' protocol appears unsupported.
error actually masks some exception. It's worth noting that APScheduler 4 requires AnyIO 4 which does not work yet with FastAPI. That said, I tried with the latest master version and it seems to work fine. Could you try again with the latest alpha release?Thank you for your response. I have conducted some tests and have determined that the issue lies in the conflict of creating database tables. Upon reviewing your source code, I have found that setting the following parameter should resolve the error that occurs upon subsequent runs:
engine = create_async_engine("postgresql+asyncpg://postgres:password@localhost/testdb") data_store = SQLAlchemyDataStore(engine) data_store.start_from_scratch = True
I apologize for any confusion caused. It seems that my previous understanding was incorrect. Upon further consideration, I believe I have identified the true cause of the error. It appears that when adding events, the duplication of IDs upon subsequent runs is leading to the failure of database insertion.
await self.scheduler.add_schedule(
tick, IntervalTrigger(seconds=1), id="tick"
)
It appears that when adding events, the duplication of IDs upon subsequent runs is leading to the failure of database insertion.
No, the scheduler just updates the schedule in such cases, and does not try to insert a duplicate schedule. Otherwise I would be seeing errors too on subsequent runs. Are you seeing issues on the latest alpha?
I have tested it again, using both the latest version and the old version, and the previous issue did not reoccur. You can go ahead and close this issue. Thanks again for your response and the effort put into the project.
Things to check first
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
APScheduler==4.0.0a3
What happened?
When executing the demo examples/web/asgi_fastapi.py, I encounter an issue where it fails to run for the second time. On each subsequent run, I am required to delete the tables from the database before proceeding.
The initial run proceeds without errors, but upon subsequent executions, an error is encountered. First-time execution log:
Subsequent execution log:
No specific error message is being provided.
It appears that there is no validation being performed for existing database tables.
How can we reproduce the bug?
use examples/web/asgi_fastapi.py code.