[Gambas-user] shell command with gb.web.gui

Benoît Minisini g4mba5 at gmail.com
Mon Dec 7 21:26:47 CET 2020


Le 07/12/2020 à 20:23, Mayost Sharon a écrit :
> Hello
> 
> gambas 3.15.2
> fedora 32 64 bit
> 
> I use gb.web.gui
> 
> There's a problem when I finish downloading any file:
> Event: Finish
> I run a command through the shell
> For example I wait 10 seconds "shell sleep 10" (sample only)
> Indeed it works well as long as I am through the IDE
> But if I compile and put the file on an HTTPD server in cgi-bin
> For some reason when he finishes the standby command
> The entire session is deleted and restarts
> The thing is that if I execute the same command at the push of a button it works well
> 
> Sorry for my English, so I'm attaching a demo
> Attached are Gambas files
> 

You must not use SLEEP, because the web server waits for you answer, and 
you may reach the session timeout (which is five minutes by default).

You must run your process asynchronously, and use its "Kill" event to 
get its answer.

You must understand that your project is normally suspended, and is 
woken up each time a request is sent by the browser.

If you run your sub-process synchronously, you may reach the session 
timeout.

If you run your sub-process asynchronously, your project will return 
(almost) immediately and be suspended until the next request, while the 
sub-process run in the background.

When your projet wakes up again, if the sub-process has been terminated 
meanwhile, you should normally get the Kill event immediately, and then 
you can return the result in the request answer.

If you want your user think that al is synchronously, you have to 
disable the GUI when the user starts the action, and enables it back 
when you get the result of the sub-process.

I hope it's clearer now, it's a bit difficult to explain in english.

In other words: don't be synchronous, be asynchronous using the event loop!

Regards,

-- 
Benoît Minisini


More information about the User mailing list