server function not triggered in some cases

73 views
Skip to first unread message

Yebach

unread,
Jan 7, 2016, 12:47:47 PM1/7/16
to web2py-users
Hello

Using web2py (Version 2.8.2-stable+timestamp.2013.11.28.13.54.07), on 64-bit Windows, I have the following problem

User triggers an engine that does some work and this engine creates an txt file with results. While engine is still calculating (engine is creating better and better results), user can check the current results, clicking on icon that provides a view (of course there is a controller function alos). These results are read from txt file. 

Now some times while calculating this function is not triggered. I used Microsoft network monitor to monitor requests etc. I can see the request coming to server, but the function is not triggered.
Some time the first time the user clicks to check the result the function is triggered but on refresh again request comes to server but no results (meaning fucniton not triggered)
Any suggestions why these behavior ocures?

Thank You

Niphlod

unread,
Jan 7, 2016, 2:40:05 PM1/7/16
to web2py-users
what are you to run the actual calculation ? because if you're using the webserver, you may need to pay attention to the fact that there is ALWAYS a timeout imposed on the request coming in to avoid runaway calculations. 

Yebach

unread,
Jan 7, 2016, 2:58:04 PM1/7/16
to web2py-users
The calculation runs on the same server. When user starts a calculation a function creates a txt file and puts it in a folder in my application. The engine checks if the file is there. if file exists it starts a calculation. The way user stops calculation another function actually deletes that file and that is it. But the refresh button or view button as we call it  (the function associated with ), just checks the out file engine produces. 

How can I go around timeout? I am not sure I understand your answer

Thank you

Niphlod

unread,
Jan 8, 2016, 5:04:05 AM1/8/16
to web2py-users
you're missing the point. the "calculation" is running inside the web2py environment or on an external process ?

Vid Ogris

unread,
Jan 8, 2016, 6:32:20 AM1/8/16
to web...@googlegroups.com
It is external process

--
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/-ZHjMW2ke2o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Niphlod

unread,
Jan 8, 2016, 11:23:15 AM1/8/16
to web2py-users
so what's the issue with web2py if your external process sometimes drops dead ? who starts the external process ?

Vid Ogris

unread,
Jan 11, 2016, 6:46:05 AM1/11/16
to web...@googlegroups.com
External process never drops dead. The request comes to server but sometimes, the function that reads the file, an external process created is not started. There are no issues with external process. 

Niphlod

unread,
Jan 11, 2016, 8:17:53 AM1/11/16
to web2py-users
I'm sorry but you need to rephrase your issue then. 

Vid Ogris

unread,
Jan 11, 2016, 10:08:59 AM1/11/16
to web...@googlegroups.com
I went trough my code again

This is the way i start my eternal process

try:
       
        count = 0
        while ( count < 10 and ( os.path.isfile(outPath))):
            count += 1 
  
            os.remove(outPath)
            time.sleep(0.05)
        
        # Run woshi engine
        path_1 =  os.path.join(path, 'e1')
        os.chdir(path_1)
       
        p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout = subprocess.PIPE)
        
        return dict(status = 1)

Is it possible this has an effect on the whole situation? But like I said. The problem is that while process is executing and woshi_engine.exe creates an txt file I read with a cirtain function, this function is not triggered, although the request comes to server.



Niphlod

unread,
Jan 11, 2016, 2:47:45 PM1/11/16
to web2py-users
sooooooooooo. finally. 
The external process is started from within web2py. 
Which is handled by a webserver. 
Which ALWAYS imposes a timeout.
You can't start a neverending process inside a web request. That's why long-running processes NEED to be managed OUTSIDE web2py (and why web2py provides a nifty out-of-band processor called scheduler)

PS: it was the first thing I said.

Yebach

unread,
Jan 18, 2016, 6:43:36 AM1/18/16
to web2py-users
I do not think you can treat it as a never ending process. 

There is a *.exe program that is started when user sends request, and also user stops it whenever he/she wants. I do not know how to treat this kind of process.I tried with scheduler but there was the same problem 

I really need some help here.
Anyone?
Thank you

Niphlod

unread,
Jan 18, 2016, 7:54:48 AM1/18/16
to web2py-users
"neverending" for this sake is "running for more than the usual timeout imposed by webservers" which is 60 seconds.

a task can be queued and also stopped via the scheduler APIs (queue_task and stop_task) 

Yebach

unread,
Jan 20, 2016, 4:02:04 AM1/20/16
to web2py-users
The issues solved with a great help of Niphlod. I answered my own question on stackoverflow. 

please correct if it is not correct


Thank you 

Niphlod

unread,
Jan 20, 2016, 8:29:19 AM1/20/16
to web2py-users
perfect. Glad that everything is working fine.
Reply all
Reply to author
Forward
0 new messages