Let’s look at a demo to reproduce this error:
from apscheduler.schedulers.blocking import BlockingScheduler import time from threading import Timer from datetime import datetime def test1(who): print("hello") print(datetime.now()) time.sleep(20) print("this is %s" %who) print(datetime.now()) def scheduler_test(): scheduler = BlockingScheduler() i=0 while i<1: scheduler.add_job(test1, 'interval', seconds=10, id='test_job'+str(i), args=["xiao"+str(i)],next_run_time=datetime.now()) i=i+1 print("mmmmmmm") scheduler.start() def timer1(who): who_tmp=who test1(who) Timer(20, timer_test, kwargs={'who': who_tmp}).start() def timer_test(): i=0 while i<3: timer1("xiao"+str(i)) if __name__ == '__main__': #timer_test() scheduler_test() print("when")
You can see that the interval length is less than the execution length of the job, it will trigger this error maximum number of running instances reached
There are two solutions, 1, modify the interval duration of the add_job interface to make it greater than the execution duration of the job 2, add a parameter to the add_job interface, such as max_instances=20, to adjust the number of concurrency allowed.
Similar Posts:
- [Solved] C# Windows service reports an error when the service is started. The service did not respond to the start or control request in time, error code 1053
- ValueError: day is out of range for month [How to Solve]
- ValueError: day is out of range for month [How to Solve]
- timer_create ,timer_settime,timer_delete
- Code a packet sniffer in python with pcapy exte…
- [Solved] PythonTypeError: ‘<' not supported between instances of 'str' and 'int'
- [Solved] Python Error: datetime.datetime is not JSON serializable
- Swift 3.0: How to solve the problem of timer circular reference
- Pytorch dataloader Error: RuntimeError: stack expects each tensor to be equal size, but got [4] at entry 0 and [5] at entry 1
- Configuring Google Android test station for Ubuntu