-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App crash #952
Comments
C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Scripts\python.exe D:\GoogleDrive\projects\cars-backend\worker.py
INFO:apscheduler._schedulers.async_:Added new schedule (task='__main__:tick', trigger=IntervalTrigger(seconds=1, start_time='2024-08-10 01:49:19.465905+03:00')); next run time at 2024-08-10 01:49:19.465905+03:00
INFO:apscheduler._schedulers.async_:Cleaned up expired job results and finished schedules
INFO:apscheduler._schedulers.async_:Scheduler started
INFO:apscheduler._schedulers.async_:Cleaned up expired job results and finished schedules
Hello, the time is 2024-08-10 02:05:59.468589
INFO:apscheduler._schedulers.async_:Job 2474e627-e5ed-4994-a506-1cec5575e37e completed successfully
INFO:apscheduler._schedulers.async_:Job 0be9b4c3-101d-4382-bd2d-8dedcf6f1603 completed successfully
Hello, the time is 2024-08-10 02:06:00.479031
Hello, the time is 2024-08-10 02:06:01.476233
INFO:apscheduler._schedulers.async_:Job e38794ac-433d-4f89-845e-715ad72a6fd6 completed successfully
Hello, the time is 2024-08-10 02:06:12.497892
Hello, the time is 2024-08-10 02:06:13.480893
INFO:apscheduler._schedulers.async_:Job ca93c653-5326-49ce-853b-3ecb4b1003a7 completed successfully
INFO:apscheduler._schedulers.async_:Job 45c401da-fe3d-4f7a-b1ea-753f82edb551 completed successfully
Hello, the time is 2024-08-10 02:06:14.495734
INFO:apscheduler._schedulers.async_:Job 170ee964-f072-457d-b0fb-42314266635b completed successfully
Hello, the time is 2024-08-10 02:06:15.466828
INFO:apscheduler._schedulers.async_:Job 620ca19b-81f8-4966-aae5-3908c07d9821 completed successfully
Hello, the time is 2024-08-10 02:06:16.479123
INFO:apscheduler._schedulers.async_:Job 416c1f66-8303-4da2-ab06-d1817a5bfc11 completed successfully
Hello, the time is 2024-08-10 02:06:17.474106
INFO:apscheduler._schedulers.async_:Job c9eabd10-a76b-4172-8d31-b2947f112a09 completed successfully
Hello, the time is 2024-08-10 02:06:18.472178
Hello, the time is 2024-08-10 02:06:19.467102
INFO:apscheduler._schedulers.async_:Job bdcfa37b-4672-4dad-9d9c-0ffc0be4533f completed successfully
INFO:apscheduler._schedulers.async_:Job 706345c9-58bb-4787-a844-6a5003de1475 completed successfully
Hello, the time is 2024-08-10 02:06:20.480103
Hello, the time is 2024-08-10 02:06:21.479911
INFO:apscheduler._schedulers.async_:Job 7f6891b8-0ac5-40ec-96bc-5f30ee002c91 completed successfully
INFO:apscheduler._schedulers.async_:Job efc876d0-aa0b-4ab9-aadc-f8f18d322fcf completed successfully
Hello, the time is 2024-08-10 02:06:22.475297
...
Hello, the time is 2024-08-10 02:06:28.470972
INFO:apscheduler._schedulers.async_:Job 2474e627-e5ed-4994-a506-1cec5575e37e completed successfully
INFO:apscheduler._schedulers.async_:Job 6405a281-8415-4e32-a3ec-a91d5c188820 completed successfully
INFO:apscheduler._schedulers.async_:Job 9e4d1616-1262-4185-b12e-981ddf76eb73 was cancelled
INFO:apscheduler._schedulers.async_:Job 4236cf58-8a6e-41e1-bedf-f72d6810acfd was cancelled
INFO:apscheduler._schedulers.async_:Job eed93c7a-854c-476b-bec6-542387f7fd20 was cancelled
...
INFO:apscheduler._schedulers.async_:Job 5c428483-8908-4b83-9093-2216f5cfe78c was cancelled
INFO:apscheduler._schedulers.async_:Job 6fc1559c-9e61-475b-9621-015688db66c5 was cancelled
INFO:apscheduler._schedulers.async_:Job 3f23a3ba-a80b-4d6f-af7a-417bebb8321d was cancelled
INFO:apscheduler._schedulers.async_:Job 1fa9cb30-af0b-417f-9f79-63ae78c0ed55 was cancelled
ERROR:apscheduler._schedulers.async_:Scheduler crashed
+ Exception Group Traceback (most recent call last):
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\apscheduler\_schedulers\async_.py", line 784, in run_until_stopped
| async with create_task_group() as task_group:
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\anyio\_backends\_asyncio.py", line 680, in __aexit__
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\apscheduler\_schedulers\async_.py", line 1018, in _process_jobs
| await wakeup_event.wait()
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\anyio\_backends\_asyncio.py", line 1662, in wait
| await self._event.wait()
| File "C:\Python311\Lib\asyncio\locks.py", line 213, in wait
| await fut
| asyncio.exceptions.CancelledError: Cancelled by cancel scope 26e138be0d0
|
| During handling of the above exception, another exception occurred:
|
| Exception Group Traceback (most recent call last):
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\apscheduler\_schedulers\async_.py", line 988, in _process_jobs
.
.
.
packages\apscheduler\_schedulers\async_.py", line 1076, in _run_job
| self._running_jobs.remove(job.id)
| KeyError: UUID('706345c9-58bb-4787-a844-6a5003de1475')
+---------------- 14 ----------------
| Traceback (most recent call last):
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\apscheduler\_schedulers\async_.py", line 1076, in _run_job
| self._running_jobs.remove(job.id)
| KeyError: UUID('620ca19b-81f8-4966-aae5-3908c07d9821')
+---------------- 15 ----------------
| Traceback (most recent call last):
| File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\cars-pRqyGtAI-py3.11\Lib\site-packages\apscheduler\_schedulers\async_.py", line 1076, in _run_job
| self._running_jobs.remove(job.id)
| KeyError: UUID('db37c1a7-46d5-41c5-9317-55aba714c9fe')
+---------------- ... ----------------
| and 2874 more exceptions
+------------------------------------
Process finished with exit code 1
|
Could you try again with the |
same issue, additionally check inside docker container - same( |
Ok, so the example you pasted in the description should reproduce the issue? After how much time? |
Would you mind pasting a traceback when using Also, is the long sleep time of 1000 seconds truly necessary to reproduce the issue? Will it not happen with a shorter wait time? I reduced the sleep time to 30 seconds, and cannot reproduce the issue. |
import time
from asyncio import run, sleep
from datetime import datetime
from apscheduler import AsyncScheduler
from apscheduler.triggers.interval import IntervalTrigger
async def tick():
await sleep(100)
print("Hello, the time is", datetime.now())
async def main():
start_time = time.time()
async with AsyncScheduler() as scheduler:
await scheduler.add_schedule(tick, IntervalTrigger(seconds=1))
await scheduler.run_until_stopped()
end_time = time.time()
elapsed_time = end_time - start_time
print(f"Scheduler ran for {elapsed_time:.2f} seconds.")
run(main()) I change code, crash after 3-5 minutes, always in real case - yes, I have long time task - 5-10 minutes and need one instance only (if the task fails - autorepeat) |
Ok, I was finally able to reproduce the issue on my end, thanks! I'll investigate and let you know when I have a fix. |
I'm seeing duplicate job IDs being added to |
The data store is letting the scheduler acquire an already running job. This explains the |
Ok, I figured it out. This happens because of the wrong looping condition in the nested function |
I have a test that reproduces the issue, but I still need to refactor it to not have to |
Well, I got it working like I wanted...but the test that should fail without the patch is only failing for the memory data store. I'm investigating why it's not failing for sqlalchemy/mongodb stores. |
I was able to reproduce the error using MongoDB Data Store. from asyncio import run, sleep
from datetime import datetime
from apscheduler import AsyncScheduler
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.datastores.mongodb import MongoDBDataStore
MONGO_DB_URI = 'mongodb://127.0.0.1:27017'
MONGO_DB_NAME = 'try_bug_aps'
data_store = MongoDBDataStore(
client_or_uri=MONGO_DB_URI,
database=MONGO_DB_NAME
)
async def tick():
await sleep(60)
print("Hello, the time is", datetime.now())
async def main():
async with AsyncScheduler(data_store=data_store) as scheduler:
await scheduler.add_schedule(tick, IntervalTrigger(seconds=1))
await scheduler.run_until_stopped()
run(main()) My execution logs
|
Turns out that the bug indirectly reported in #953 was causing the test failure not to be triggered. |
Sorry for I posted a simillar issue but almost exact same issue I got with sqlachemdemy. and I used time.sleep(2) in my function.. Is there any solution? |
Yes, running the |
Hi, any time to upgrade to pypi? |
I will once I've resolved a bunch of outstanding issues with the code. |
TypeError: Scheduler.add_schedule() got an unexpected keyword argument 'max_running_jobs' Hi, just want to ask, thank u so much for the work, but can we just make the api a little bit stable? |
No, v4.0 is in alpha, meaning that the API is not stable. It will stabilize somewhat more when it hits beta, and completely so when it reaches a final release. |
Hopefully we won't change all the codes again when beta and final. -.- |
You should be prepared for that. Also, the data store schemas may change while the project is in alpha. I will try to freeze the schema at least when entering the beta phase. This is an in-development version after all, not recommended for serious production use yet. |
Posting numerous different versions of the API is not beneficial for your project. Currently, artificial intelligence is trending. Training AI with incorrect version corpora only leads to increased confusion among people regarding this library. Nevertheless, scheduling is not an overly complicated matter. Do not overcomplicate things. Users simply desire a library that can handle scheduling. That is all. |
Maybe you should fork the project then, as you clearly know better than me how to design APIs and how all this should work. It's really simple, after all! |
@lucasjinreal How do you suppose developers make changes to their projects without causing issues for AI? Should we all just freeze our code to suit what LLMs have been trained on? Of course not. If you really care to use an LLM to help with this, that's on you. Consider reading the docs for this project instead, as they're quite good.
If it's so simple, why are you turning to this library at all? Why aren't you using the published and stable version of this library? |
I can just agree to what @WillDaSilva said. It seems pretty respectless from you @lucasjinreal . Nobody forces you to use this. And the owner of a repo has the right to do whatever they want with the project😅 |
@lucasjinreal Welcome to the world of open-source, if this project doesn't suit your needs you can just fork it and maintain it yourself 😄. @agronholm is probably spending a lot of his free time working on this for free, you should be grateful that he is sharing his work with us. Also if you really need to have the latest version on PyPi, you can just pull the master branch locally and link it with your
|
Better yet: |
@doluk @WillDaSilva Please refrain from taking things personally. I did not imply that this is not a good library. In fact, I previously expressed my appreciation to @agronholm for his excellent work. I merely stated that posting numerous different API designs across multiple versions can cause confusion for users. If you do not think this is the case, then you may disregard my opinion. Rather than posting non-constructive and emotionally venting comments. I again, much apprecaited to @agronholm for his contribution for this lib. I have decided to abandon the use of this library due to the disrespectful attitude of its owner and the rudeness of its followers. The scheduler is far superior. |
A good API is important for the developer experience, and so I have to change it during development as I run into snags where the previous API design doesn't work. I have pledged to uphold the Semantic Versioning 2.0 standard in my projects in order to not cause breakage between minor and patch updates, but even that standard allows for development releases to break the API arbitrarily. This leads to my next question about your expectations: do you expect me to foresee every single design problem and design a perfect API on the first try, or do you expect me to keep a bad, non-working API just so some random user won't be upset by the breakage? I'm asking for an honest reply. |
As everyone else pointed out, you're the one with the disrespectful attitude. And what scheduler are you talking about? EDIT: probably this one. |
@agronholm seems there is not much missing to complete this issue. Is there anything we can help with? |
All the commentary has muddled the original issue; I can't even be sure if it's actually been fixed or not. So you can help by refreshing my memory :) |
I just checked and the error no longer occurs for me on the master branch. It used to occur when running the sample code: #952 (comment) However, I just ran this same code on the master branch and the problem did not occur. So I believe this has been fixed. |
Things to check first
I have checked that my issue does not already have a solution in the FAQ
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Version
4.0.0a5
What happened?
work app
How can we reproduce the bug?
after some time app crash (windows 11, python 3.11.9):
The text was updated successfully, but these errors were encountered: