(sorry, I've deleted my previous message because I have more detailed information).
Thank you for pointing that out, I had seen that issue but I missed out that I had to use Scheduler(..., with_spawn=True) so I did that change and, apparently, scheduler is stable (hasn't crashed so far). However, since that change, all the tasks that are from a different app that the one from where the scheduler was run, fail with this traceback:
Traceback (most recent call last): File "/home/limon/medios/gluon/scheduler.py", line 494, in executor functions = current._scheduler.tasks AttributeError: '_thread._local' object has no attribute '_scheduler'
Let me explain a bit more: I have one web2py instance with several applications, each one with its own database. One of these apps is the main one and the scheduler connects to its database.
...web2py/applications/main/...
...web2py/applications/app1/...
...web2py/applications/app2/...
I run three scheduler workers for the main app with this command:
/opt/virtualenvs/py39/bin/python /home/limon/web2py/web2py.py -K main,main,main
In applications/main/models/scheduler.py I instantiate the Scheduler like this:
scheduler = Scheduler(db, max_empty_runs=0, heartbeat=5, use_spawn=True)
And then, from several parts of my application I queue tasks. Some of these tasks are defined in the "main" application, but some others are defined in "app1" or "app2".
Well, since the change to Scheduler(..., use_spawn=True) all the tasks within "main" application run ok, but all the other ones fail with the traceback I showed before.
Notice I run the three scheduler workers for "main" application, I'm not sure if that has something to do with the issue. But I can confirm all this setup was working smoothly before use_spawn=True.
What could be happening?
Any help will be much appreciated.
I'll keep investigating and post here if I find something.
Thanks!