nope. what it really happens is that scheduler module "register itself"
under the current namespace. When you do -K , it just spawns a process that
executes "from gluon import current;current._scheduler.loop()" in the
context of the app.
Given that DAL under the hood represents a connection, and that a
connection can't be serialized, that connection can only be used in the
outer-scope, and another one, for the inner scope, is initiated to support
operations in that thread.
The only safe way to do that is to build a connection with the same URI,
but that DOESN'T reexecute all the models, hence your issue.
On Friday, June 3, 2016 at 11:09:18 PM UTC+2, Bart wrote:
>
> Thanks Niphlod, It works!
>
> I added
> self.db_thread.executesql("set search_path to scheduler, auth, ... ;")
> in gluon/scheduler.py
> after the self.db_thread = DAL( .... line and before the
> self.define_tables( ... line
>
> I am aware of the fact that it is not supported, but the database uses a
> strict schema policy so i don't have a choice really.
>
> I am wondering how worker startup works when the python web2py.py -K
> myapp statement is executed.
> How does the scheduler get the database uri, if the models aren't executed
> at scheduler worker startup?
> Does scheduler only search for de db - DAL(... statement, omitting the
> other code?
>
> Op vrijdag 3 juni 2016 20:24:01 UTC+2 schreef Niphlod:
>>
>> the scheduler though doesn't know anything about the search path when it
>> rebuilds its own model... that's why setting search_path is undocumented ^_^
>>
>> you can try fiddling with the source of the scheduler (along these lines
>> https://github.com/web2py/web2py/blob/master/gluon/scheduler.py#L948) to
>> set the same search path.
>>
>> Please be aware that even if it seems to work, support for it is not
>> assured (so use at your own risk)
>>
>> On Friday, June 3, 2016 at 7:19:02 PM UTC+2, Bart wrote:
>>>
>>> Hi Niphlod,
>>>
>>> Normally i just put a record in the scheduler_task table with appadmin.
>>> That works fine (no errors), but nothing happens because the scheduler
>>> worker is not running.
>>>
>>> In db.py the database schema is set via db.executesql("set search_path
>>> to auth,scheduler, ... ;")
>>>
>>> In case migrate is True, the search_path is set to scheduler, auth, ...
>>> just before the scheduler = Scheduler(db) statement.
>>>
>>>
>>>
>>> Op vrijdag 3 juni 2016 18:35:07 UTC+2 schreef Niphlod:
>>>>
>>>> what happens when you try to queue a task from the app ? AFAIK I'd be
>>>> eager to know how can it work if there is no "public" schema, unless you
>>>> tinkered with scheduler's table definitions
>>>>
>>>> On Friday, June 3, 2016 at 4:57:23 PM UTC+2, Bart wrote:
>>>>>
>>>>> Addition:
>>>>>
>>>>> I am using several schema's in the postgres database.
>>>>>
>>>>> The scheduler tables are in schema 'scheduler'
>>>>>
>>>>> Schema 'public' does not exist.
>>>>>
>>>>> Can this cause the problem?
>>>>>
>>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.