Was able to get this working. When I created the task, I originally had the 
application named something else. After renaming the application I forgot 
to update the application_name on the scheduler_task table. Once I did that 
it started working.

On Monday, November 23, 2015 at 4:33:34 PM UTC-5, Niphlod wrote:
>
> without the complete code is hard to see where the exception may raise, 
> but a serious question arises: why should you manage threads inside a 
> scheduler-executed task ? 
> At that level of abstraction, if you NEED to fine-tune code execution at 
> that level, just use a normal web2py shell.
>
> Did you try to start that machinery in web2py's shell just to avoid having 
> another layer of complexity brought by the scheduler ?
> BTW, for everybody: if you can code a function that works fine when used 
> in the web2py shell, the same will probably work when queued in the 
> Scheduler. If it doesn't in web2py's shell, start debugging from there 
> instead of inside the scheduler
>
> On Monday, November 23, 2015 at 9:54:14 PM UTC+1, Benson Myrtil wrote:
>>
>> I am getting the following error when running a scheduler task with 
>> threading:
>>
>> Traceback (most recent call last):   File 
>> "C:\Users\devteam\Desktop\web_apps\launchpad\production\web2py\gluon\scheduler.py",
>>  
>> line 298, in executor     functions = current._scheduler.tasks 
>> AttributeError: 'thread._local' object has no attribute '_scheduler' 
>>
>> # THREAD FUNCTION TO SET ACCOUNT
>> def set_account( kwargs ):
>>    while not q.empty( ):
>>       entry = q.get( )
>>       kwargs[ 'db_con' ].db.account.update_or_insert( kwargs[ 'db_con' 
>> ].db.account.ad_object_guid == entry[ 'ad_object_guid' ], **entry )
>>
>> # CREATE SET AMOUNT OF THREADS
>> for i in range( num_of_threads ):
>>    key = 'Thread_{0}'.format( i )
>>    db_con[ key ] = Launchpad_DB( fake_migration = True, lazy_tables = True, 
>> is_worker = True )
>>    db_con[ key ].define_account( )
>>    threads[ key ] = LaunchpadThread( i, key, set_account, db_con = db_con[ 
>> key ] )
>>    threads[ key ].start( )
>> # WAIT FOR ALL THREADS TO FINISH
>> for key in threads:
>>    threads[ key ].join( )
>>
>>
>> I am assuming the error is happening somewhere in there. I create a queue 
>> that holds all the accounts that are ready to be updated. I create a new 
>> DAL connection for each thread and pass that in.
>>
>> Any idea why I would be getting the error that I am?
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to