[web2py] Re: add task and wait the result

2014-12-01 Thread Niphlod


On Sunday, November 30, 2014 1:51:37 PM UTC+1, nick name wrote:

 Is that true even with immediate=True? If so, what is the recommended way 
 to reduce this to 0.5 seconds or so? I have an app in which a user requests 
 somethng; that request launches 1-10 other web requests, and the user keeps 
 refreshing until they all complete for the summarized result. (I will 
 probably replace this with an ajax poll or a ws notification instead later 
 on).



mine was just a general checklist before anything else, since several 
minutes point towards another whole set of issues.
in general, immediate=True shortcircuits the 5 loops wait in assigning 
newly created tasks. 
so, in worst case scenario, you'll have

|---sched.queue_task()---|---sleep---|---sleep---|---sleep---|---sleep---|---ASSIGNING---|---RUNNING---|

(without immediate)

|---sched.queue_task(,immediate=True)---|---ASSIGNING---|---RUNNING---|

(with immediate)

every |---something---| is by default a loop that last 3 seconds (the 
heartbeat value on initialization)

Simone

-- 
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.


[web2py] Re: add task and wait the result

2014-11-30 Thread Niphlod
when nothing is going wrong, and with default values, you can expect to 
queue a task and have it assigned in 15 seconds. if that's not the case, 
something is going wrong (other tasks are being processed, workers not 
ready, db contention, etc etc etc)

On Friday, November 28, 2014 8:02:15 PM UTC+1, nick name wrote:

 Related, but not exactly the same question:

 I'm submitting an immediate task in a regular (no sleep or anything -- 
 though no special commit either); I can see it's queued for seconds and 
 sometimes minutes before getting assigned and running.

 There are no other tasks waiting or running, there are one or two 
 schedulers running (one starts with app server, one independently - but I 
 tried only one with same results). Before I dig deep into debugging the 
 scehduler - is there something simple I might be missing?

 Other things:

 main app db, auth db and sched db are all different, and all are SQLite 
 files. Running on Linux. Tasks are given a uuid by me (easiest way to track 
 if something was done in a previous run or not - uuid reflects the exact 
 operation needed).

 Thanks in advance.

 On Friday, November 28, 2014 7:30:44 PM UTC+2, Niphlod wrote:

 def test():
  newid = sched.queue_task(, immediate=True)
  db.commit() #the db instance where the scheduler is
  while True:
  rtn = sched.task_status(newid)
  if rtn.status == 'COMPLETED':
...blablabla
break
  time.sleep(3)


 not tested (haven't a web2py to try it on ATM) but you get the idea

 On Friday, November 28, 2014 7:30:18 AM UTC+1, Manuele wrote:

 Hi, 
 I would like to add an immediate task to the scheduler and wait for the 
 result within the same submit. Is it possible? How? 

 Thank you very mutch 

 Manuele 



-- 
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.


[web2py] Re: add task and wait the result

2014-11-30 Thread nick name
Is that true even with immediate=True? If so, what is the recommended way 
to reduce this to 0.5 seconds or so? I have an app in which a user requests 
somethng; that request launches 1-10 other web requests, and the user keeps 
refreshing until they all complete for the summarized result. (I will 
probably replace this with an ajax poll or a ws notification instead later 
on).

Any time before the first assignment is essentially dead time that I 
would like to avoid. What's the best way to do so?
I understand the scheduler might not have been designed for this setting 
(although otherwise it is perfect) - if I want to hack it, to e.g. checkl 
some shared flag (e.g. create a file) that will be signaled on queue_task) 
to try to assign things, would that work? would that be accepted upstream? 
Or should I just implement my own queue/scheduler for this?

I cannot reproduce the several minute wait right now - I'm now getting the 
expected 10-15 seconds (Possibly there was a database contention or 
something like that that caused database access to stall - but the logging 
looked like things were running). But what could go wrong that would 
cause minutes of delay?

On Sunday, November 30, 2014 2:43:15 PM UTC+2, Niphlod wrote:

 when nothing is going wrong, and with default values, you can expect to 
 queue a task and have it assigned in 15 seconds. if that's not the case, 
 something is going wrong (other tasks are being processed, workers not 
 ready, db contention, etc etc etc)

 On Friday, November 28, 2014 8:02:15 PM UTC+1, nick name wrote:

 Related, but not exactly the same question:

 I'm submitting an immediate task in a regular (no sleep or anything -- 
 though no special commit either); I can see it's queued for seconds and 
 sometimes minutes before getting assigned and running.

 There are no other tasks waiting or running, there are one or two 
 schedulers running (one starts with app server, one independently - but I 
 tried only one with same results). Before I dig deep into debugging the 
 scehduler - is there something simple I might be missing?

 Other things:

 main app db, auth db and sched db are all different, and all are SQLite 
 files. Running on Linux. Tasks are given a uuid by me (easiest way to track 
 if something was done in a previous run or not - uuid reflects the exact 
 operation needed).

 Thanks in advance.

 On Friday, November 28, 2014 7:30:44 PM UTC+2, Niphlod wrote:

 def test():
  newid = sched.queue_task(, immediate=True)
  db.commit() #the db instance where the scheduler is
  while True:
  rtn = sched.task_status(newid)
  if rtn.status == 'COMPLETED':
...blablabla
break
  time.sleep(3)


 not tested (haven't a web2py to try it on ATM) but you get the idea

 On Friday, November 28, 2014 7:30:18 AM UTC+1, Manuele wrote:

 Hi, 
 I would like to add an immediate task to the scheduler and wait for the 
 result within the same submit. Is it possible? How? 

 Thank you very mutch 

 Manuele 



-- 
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.


Re: [web2py] Re: add task and wait the result

2014-11-29 Thread Manuele Pesenti
Il 28/11/14 18:30, Niphlod ha scritto:
 |
 deftest():
  newid =sched.queue_task(,immediate=True)
  db.commit()#the db instance where the scheduler is
  whileTrue:
  rtn =sched.task_status(newid)
  ifrtn.status =='COMPLETED':
...blablabla
break
  time.sleep(3)
 |


 not tested (haven't a web2py to try it on ATM) but you get the idea

Yes I got it now... thanks a lot Niphlod... I'll try

Cheers

M.

-- 
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.


[web2py] Re: add task and wait the result

2014-11-28 Thread Niphlod
def test():
 newid = sched.queue_task(, immediate=True)
 db.commit() #the db instance where the scheduler is
 while True:
 rtn = sched.task_status(newid)
 if rtn.status == 'COMPLETED':
   ...blablabla
   break
 time.sleep(3)


not tested (haven't a web2py to try it on ATM) but you get the idea

On Friday, November 28, 2014 7:30:18 AM UTC+1, Manuele wrote:

 Hi, 
 I would like to add an immediate task to the scheduler and wait for the 
 result within the same submit. Is it possible? How? 

 Thank you very mutch 

 Manuele 


-- 
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.


[web2py] Re: add task and wait the result

2014-11-28 Thread nick name
Related, but not exactly the same question:

I'm submitting an immediate task in a regular (no sleep or anything -- 
though no special commit either); I can see it's queued for seconds and 
sometimes minutes before getting assigned and running.

There are no other tasks waiting or running, there are one or two 
schedulers running (one starts with app server, one independently - but I 
tried only one with same results). Before I dig deep into debugging the 
scehduler - is there something simple I might be missing?

Other things:

main app db, auth db and sched db are all different, and all are SQLite 
files. Running on Linux. Tasks are given a uuid by me (easiest way to track 
if something was done in a previous run or not - uuid reflects the exact 
operation needed).

Thanks in advance.

On Friday, November 28, 2014 7:30:44 PM UTC+2, Niphlod wrote:

 def test():
  newid = sched.queue_task(, immediate=True)
  db.commit() #the db instance where the scheduler is
  while True:
  rtn = sched.task_status(newid)
  if rtn.status == 'COMPLETED':
...blablabla
break
  time.sleep(3)


 not tested (haven't a web2py to try it on ATM) but you get the idea

 On Friday, November 28, 2014 7:30:18 AM UTC+1, Manuele wrote:

 Hi, 
 I would like to add an immediate task to the scheduler and wait for the 
 result within the same submit. Is it possible? How? 

 Thank you very mutch 

 Manuele 



-- 
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.