Hey there! Thanks for pointing that out. 
I had already seen that issue but I missed out that I had to instantiate 
Scheduler() with use_spawn=True. I've made that change, but now I have this 
error:

Traceback (most recent call last): File 
"/var/www/medios/gluon/scheduler.py", line 491, in executor functions = 
current._scheduler.tasks AttributeError: '_thread._local' object has no 
attribute '_scheduler'

I think this happens because I store the scheduler in the "current" object 
after instantiating it, and then I use it from within some of my scheduled 
tasks. Should I achieve this in a different way?

El miércoles, 21 de junio de 2023 a la(s) 07:08:37 UTC-3, Massimiliano 
escribió:

> There was an issue but should be fixed now.
>
> https://github.com/web2py/web2py/issues/1999
>
>
> Il giorno lun 19 giu 2023 alle ore 20:57 Lisandro <rostagno...@gmail.com> 
> ha scritto:
>
>> I've recently upgraded to web2py Version 
>> 2.24.1-stable+timestamp.2023.03.23.05.07.17
>> It's running on python 3.9.14, Rocky Linux RHEL9, using PostgreSQL 15.2 
>> for database.
>>
>> Since I did the upgrade, the scheduler fails from time to time with this 
>> traceback:
>>
>> ERROR:web2py.scheduler.main#1531711:    error storing result
>> Traceback (most recent call last):
>>   File "/var/www/medios/gluon/scheduler.py", line 1077, in 
>> wrapped_report_task
>>     self.report_task(task, task_report)
>>   File "/var/www/medios/gluon/scheduler.py", line 1101, in report_task
>>     db(sr.id == task.run_id).update(
>>   File "/var/www/medios/gluon/packages/dal/pydal/objects.py", line 2789, 
>> in update
>>     ret = db._adapter.update(table, self.query, row.op_values())
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 586, in update
>>     raise e
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 581, in update
>>     self.execute(sql)
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/__init__.py", 
>> line 69, in wrap
>>     return f(*args, **kwargs)
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 468, in execute
>>     rv = self.cursor.execute(command, *args[1:], **kwargs)
>> psycopg2.OperationalError: server closed the connection unexpectedly
>>         This probably means the server terminated abnormally
>>         before or while processing the request.
>> Traceback (most recent call last):
>>   File "/var/www/medios/gluon/scheduler.py", line 1077, in 
>> wrapped_report_task
>>     self.report_task(task, task_report)
>>   File "/var/www/medios/gluon/scheduler.py", line 1101, in report_task
>>     db(sr.id == task.run_id).update(
>>   File "/var/www/medios/gluon/packages/dal/pydal/objects.py", line 2789, 
>> in update
>>     ret = db._adapter.update(table, self.query, row.op_values())
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 586, in update
>>     raise e
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 581, in update
>>     self.execute(sql)
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/__init__.py", 
>> line 69, in wrap
>>     return f(*args, **kwargs)
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 468, in execute
>>     rv = self.cursor.execute(command, *args[1:], **kwargs)
>> psycopg2.OperationalError: server closed the connection unexpectedly
>>         This probably means the server terminated abnormally
>>         before or while processing the request.
>> During handling of the above exception, another exception occurred:
>> Traceback (most recent call last):
>>   File "/var/www/medios/gluon/shell.py", line 321, in run
>>     exec(python_code, _env)
>>   File "<string>", line 1, in <module>
>>   File "/var/www/medios/gluon/scheduler.py", line 949, in loop
>>     self.wrapped_report_task(task, self.execute(task))
>>   File "/var/www/medios/gluon/scheduler.py", line 1082, in 
>> wrapped_report_task
>>     db.rollback()
>>   File "/var/www/medios/gluon/packages/dal/pydal/base.py", line 825, in 
>> rollback
>>     self._adapter.rollback()
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/__init__.py", 
>> line 57, in wrap
>>     return f(*args, **kwargs)
>>   File "/var/www/medios/gluon/packages/dal/pydal/adapters/base.py", line 
>> 1012, in rollback
>>     return self.connection.rollback()
>> psycopg2.InterfaceError: connection already closed
>>
>>
>> I've checked PostgreSQL logs but there is no error or apparent problem at 
>> the time scheduler fails. The database instance has several databases and 
>> no error log is reported, everything runs smoothly. It's just the scheduler 
>> that reports that error (and after it, it doesn't run anymore). Where else 
>> should I look?
>>
>> Any help will be much appreciated.
>> Warm regards,
>> Lisandro
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/9ffdc6f1-8448-4784-a344-7f176545e9d9n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/9ffdc6f1-8448-4784-a344-7f176545e9d9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Massimiliano
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b222e106-44a3-48a6-8eb5-5dd24408b664n%40googlegroups.com.

Reply via email to