[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help programming processes (monitoring subordinate processes)



I have a large natural-language program and a pretty large test set.
The program has just gotten to a "quasi-stable" state:  by and large
it doesn't break anymore.  So I want to run it over the entire
test-set, unsupervised, and come back at the end of some long period
of time, and see which elements are working properly.

My initial idea was to write a function which will spawn a process
that would run my program.  This function would allow the program to
run for a specified length of time and then give up.  It would also
watch the subordinate program to see if it was scrrewing up.  At the
end of the specified length of time, or when the program breaks, my
function would collect some data and move on to the next element of
the test set.

Unfortunately, I haven't been able to figure out how to monitor the
subordinate process for the following conditions:
-completion of function
-error condition

Can anyone fill me in on how to do this?  It's quite possible that I
just haven't successfully indexed into the documentation, so if this
is just a stupid question, could you point me to the right manual, or
header in the Document Examiner?  I'm working in Genera 7.2.

Many thanks,

Robert

Here's the code I've been using:

;;; -*- Package: USER; Syntax: Common-Lisp; Mode: LISP; Base: 10 -*-

(defparameter *story-transcript-file* "clyde:>rpg>thesis>test-results.text"
  "This is the file to which test-thesis will send its output (unless instructed otherwise)")

(defparameter *story-source-file* "clyde:>rpg>thesis>stories"
  "This is the file to where test-thesis will find its input (unless instructed otherwise)")

(defconstant four-hours 864000)

(defun process-a-story (story)
  (declare (special *standard-input* *standard-output*))
  (with-output-to-string (*standard-output*)
    (with-input-from-string (*standard-input* story)
      (frail::story-nw))))

(defun story-process-hung-p (process)
  "This is the function we call to see if the story-reading process has gotten hung before its time runs out."
  (null (send process :runnable-p)))

(defun test-thesis (&key (output-file-name *story-transcript-file*) (stories atn::*stories*))
  (let ((test-process (make-process "Thesis-test"))
	(output-file (open output-file-name :direction :output
			   :if-does-not-exist :create :if-exists :new-version)))
    (close output-file)
    (unwind-protect
    	(loop for raw-story in stories
		      for story = (concatenate 'string raw-story " nil ")
		      	      for i from 1
			      	      do (format t 
						 "~&Now processing story:~%~A~%" story)
					 (process-preset test-process #'process-a-story story)
					 (process-reset-and-enable test-process)
					 (process-wait-with-timeout "Waiting for story"
								    four-hours #'story-process-hung-p test-process)
					 (process-interrupt test-process #'break)
					 (setf output-file (open output-file-name :direction :output
			 					 :if-does-not-exist :error :if-exists :append))
					 (format output-file "~&Stopped story number ~D at date ~D.~%Statements believed are:~%"
						 i frail::*date*)
					 (print (frail::believed-stms) output-file)
					 (format output-file "~%")
					 (close output-file))
      (progn (process-kill test-process :force)
	     (close output-file)))))