SO the problem continues.

The task was running  and was completed for some dummy code.

Now i have to go trough a folder, read a file and update file content to
database.

The task always times out and there are two files that need to be updated,
non of them are. The code is executed, but there is no db update. Also it
seems for loop is not completed. For only one file db._lastsql is printed
in db. The statement in scheduler table is ok and if i run it it inserts
data into db. Any suggestions?

My code

in scheduler.py

def saveIdOut():
    try:
        #demo koda
        #poberem statuse
        db_status = db(db.scripts.sc_status ==
11).select(db.scripts.id).as_list()
        #ggrem v mapo in pogledam katere skripte ki imajo status 11 se
dejansko izvajajo
        for rec in db_status:
            scriptId = rec["id"]
            outPath  = os.path.join(request.folder, 'engine', 'e1',
str(scriptId) + '.out')
            #preverim če obstaja datoteka
            if os.path.isfile(outPath):
                #če obstaja jo shranim v sc_engine_output
                #sparsamo out datoteko da jo lahko damo v tabelo result
                out = readOutFile(str(scriptId))
                #Vnesemo podatke v tabelo script
                db(db.scripts.id == scriptId).update(sc_engine_output = out)
                print db._lastsql

                print "out datoteka za scripto %s, arhivirana" % (str(scriptId))

        db.commit()
        return dict(status = 1)

    except Exception, e:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        print(exc_type, fname, exc_tb.tb_lineno)
        print e.__doc__
        print e.message
        return dict(status = 666)


in my controler

def save_outs():
    """
    for running scheduler
    python web2py.py --nogui --no-banner -K woshiweb -D 0

    1 hour = 3600 seconds # for period
    10 minutes = 600 seconds # for timeout
    """

    import datetime
    now = datetime.datetime.now()
    start_now = datetime.datetime.now()

    stop_time_now = (start_now + datetime.timedelta(days = 1))
    scheduler.queue_task(saveIdOut, start_time = start_now,
                   next_run_time = start_now, stop_time = stop_time_now,
                   repeats = 0, retry_failed = 2, period = 30, timeout = 15)

    print "Funkcija za arhiviranje outov AKTIVIRANA...."
    print "Glej scheduler tabele v postgresu"
    session.flash = T("Task save_outs Queued")
    redirect(URL('index.html'))


2016-11-16 2:32 GMT+08:00 Dave S <snidely....@gmail.com>:

>
>
> On Tuesday, November 15, 2016 at 2:14:21 AM UTC-8, Yebach wrote:
>>
>> Thank you guys. I finally made it. I did not quite understand the whole
>> scheduler process but i am now getting there.
>>
>> Thank you again
>>
>>
> Congratulations!  It sometimes takes a while to get the right mental
> images, doesn't it?
>
> /dps
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/FK1ygjNNjDU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Lep pozdrav

Vid Ogris

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