On Thursday, December 5, 2013 8:40:28 AM UTC+2, Yassen D. wrote:
>
>
>
> On Wednesday, December 4, 2013 10:28:43 PM UTC+2, Leonel Câmara wrote:
>>
>> Instead of rerunning the task with period, schedule new tasks every time
>> you need to go get the user's friends
>>
>
> I guess I have to create a record into the scheduler_task table, with
> some reasonable values, and then the first available worker will pick that
> up, correct?
>
What I do currently: create a scheduler in a dedicated model:
from gluon.scheduler import Scheduler
from jobs import testfunc
scheduler = Scheduler(db, dict(testfunc_task=testfunc))
Then in a controller, I do:
task_kwargs = { 'immediate': True, 'task_name': 'ImportContacts-' +
str(time.time())[:-4], }
from jobs import testfunc
scheduler.queue_task(testfunc, pargs=[request.vars.sna],
kwargs=task_kwargs)
and I get an exception saying that table socialjack.scheduler_task does not
exist (traceback below). But the table IS there, I can see it in the db
admin interface and on the MySQL console ... Please help! Thanks!
Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
File
"/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py"
<https://apps.socialjack.com/admin/default/edit/socialjack/controllers/contacts.py>,
line 236, in <module>
File "/home/www-data/web2py/gluon/globals.py", line 372, in <lambda>
self._caller = lambda f: f()
File "/home/www-data/web2py/gluon/tools.py", line 3239, in f
return action(*a, **b)
File
"/home/www-data/web2py-2.8.2/applications/socialjack/controllers/contacts.py"
<https://apps.socialjack.com/admin/default/edit/socialjack/controllers/contacts.py>,
line 54, in importcontacts
scheduler.queue_task(testfunc, pargs=[request.vars.sna], kwargs=task_kwargs)
File "/home/www-data/web2py/gluon/scheduler.py", line 983, in queue_task
**kwargs)
File "/home/www-data/web2py/gluon/dal.py", line 9114, in validate_and_insert
value,error = self[key].validate(value)
File "/home/www-data/web2py/gluon/dal.py", line 10036, in validate
(value, error) = validator(value)
File "/home/www-data/web2py/gluon/validators.py", line 668, in __call__
row = subset.select(table._id, field, limitby=(0, 1),
orderby_on_limitby=False).first()
File "/home/www-data/web2py/gluon/dal.py", line 10450, in select
return adapter.select(self.query,fields,attributes)
File "/home/www-data/web2py/gluon/dal.py", line 1861, in select
return self._select_aux(sql,fields,attributes)
File "/home/www-data/web2py/gluon/dal.py", line 1826, in _select_aux
self.execute(sql)
File "/home/www-data/web2py/gluon/dal.py", line 1948, in execute
return self.log_execute(*a, **b)
File "/home/www-data/web2py/gluon/dal.py", line 1942, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in
execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in
defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'socialjack.scheduler_task' doesn't exist")
--
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/groups/opt_out.