in reply to Shared memory and asynchronous access

I have approached this problem in a different manner

I have gui.pl start compute.pl via a start system call.

system("start perl compute.pl -arg1 arg2 arg3 arg4 sourcefile.txt > de +stinationfile.txt" );
I then have compute.pl write its progress to a file(not at the ms level), and when done write a completion message to that file. I then use another gui (gui2.pl) program to print that file to the browser (this can have a auto refresh if you like). The first gui.pl then tells the browser what the new gui address is (i pass a parm to the gui2.pl that tells it what file to monitor http://../gui2.pl?file=tracker_file). Now i had programs that took days to finish, and that was way beyond the timeout limit of a cgi session, and you wouldnt want an auto refresh either. the user just refreshed the gui2.pl page whenever they wanted to check if its done.

Ive been doing it this way for over a decade. i have little modules that make it easy to do. gui2.pl takes a specially crafted file that contains elements for many table-sections. One section displays timestamps at various milestones (input done@time, first phase done @time...), another section often displays record counts or patient counts as the process continues, and a third section displays informational progress methods. It can have as many tables as you want, and they are displayed in order of the first reference to them. Often i have warning messages displayed first, with a button that can cause the task to be terminated if the user doesnt feel the progress is viable. This requires compute.pl to record its "task id" into the tracking file so gui2.pl knows what to cancel. For the lack of a better name i now call this module websee.pm

This is an example a line is a ctime, <space> <cmd> <space> <rest>

cmd=$s gives the pid.

cmd=P prints <rest> in the bottom section

cmd=T is a table, <rest> is taken to be a <table-name> <space> <row-name> <space> <col-name> <space> <col-contents>

1483271066 $s 3880 1483271066 1483271066 P started 1483271066 T table step started 2017-01-01-05-44-26 1483271067 T table copied started 000:00:01 000:00:01 1483271067 P d-time:000:00:01 000:00:01->auto:started:copied 1483271067 T table copied ended 000:00:00 000:00:01 1483271067 P d-time:000:00:00 000:00:01->auto:ended:copied 1483271067 T table blind_scrape_4a-setup.pl started 000:00:00 000:00:0 +1 1483271067 P d-time:000:00:00 000:00:01->auto:started:blind_scrape_4a- +setup.pl 1483271067 T table blind_scrape_4a-setup.pl ended 000:00:00 000:00:01 1483271067 P d-time:000:00:00 000:00:01->auto:ended:blind_scrape_4a-se +tup.pl 1483271067 T table blind_scrape_4b-worksish.pl started 000:00:00 000:0 +0:01 1483271067 P d-time:000:00:00 000:00:01->auto:started:blind_scrape_4b- +worksish.pl 1483271701 T table blind_scrape_4b-worksish.pl ended 000:10:34 000:10: +35 1483272144 P Ended 1483272145 $e 3880 1483272145
That produced a simple page, the $s creates the "kill-button" at the top. it exists till it finds the $e line.

It has one table "table" with 4 rows and two columns (started/ended), and the contents of the cells are formatted time pairs. The first is the interstep time and the second is the cumulative time.

Under the tables, the cmd=P lines are listed

This may be extreme for your case, but it has served me well since the late 90's. Like i said, some jobs ran for days, one ran for a week, Ive used this on windows and unixen. The process of "spawning" the separate command on unixen has used "at" and other queue managers. On windows ive just used start.

Replies are listed 'Best First'.
Re^2: Shared memory and asynchronous access
by vef445 (Novice) on Apr 05, 2017 at 15:10 UTC

    Thanks for your message. I would really like to avoid using a browser or similar external tool for this small application, I'm just trying to display a progress bar / percentage and the computing is not in the scale of hours/days but seconds/minutes so I expect the user to wait here, looking at the UI.
    Besides, I'm not interested by displaying the whole history of compute.pl (I understand you were doing that), but only the last value that I'm "trying" to grab.

    Just for information, I'm currently using "qx" to execute compute.pl and capture it's exit code, which works fine.

      I went with the browser as my gui because back in 99 xwindows over a v.34 modem was a dog. I was 200 miles from the site. A browser form created the parms for the program, the browser instructed the server to start the program, and the browser monitored it via cgi. At the end of the process i could download a zip via the browser with any output files to my pc for looking at. As time progressed we had users across the world using this process to setup/run/monitor their programs. Each set of parms had its own page, where you could edit and start the run and thats where the custom link to the websee page and the last zip was. Many of the runs created html pages as output and they were linked on that page as well. I could disconnect and reconnect at will. I could start the program at home and watch it from the GF's house. I had a web tree that i could drill down to find the run i was interested in if i didnt bookmark the start page itself. If i created a new page for each combination of parms it presented a history tree of the runs as well.

        Yes, I understand, and it seems like a bulletproof system in your environment. I'm just afraid it is quite far from what I need to achieve, at least the constraints are different. Thanks for your time anyway, I appreciate.