Stopping a thread from within TPS

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Stopping a thread from within TPS

  • Creator
    Topic
  • #49588
    Carter Harrison
    Participant

    Does anybody know of a way to stop a thread from within a TPS proc?  I’d like to stop a thread based upon the particular contents of a message coming through an outbound protocol thread?  I figured I could probably find  a way to use the “hcicmd” command with a “pstop” argument, but I’m not sure how I would find the name of the process to supply to this command.  Any help would be greatly appreciated.  

    Thanks in advance.

Viewing 5 reply threads
  • Author
    Replies
    • #62609
      Charlie Bursell
      Participant

      If you remember you are running in the process directory of the same name as the process.  So the following will return the process name

         set process [file tail [pwd]]

      When you issue the hcicmd you should run it in the background.  Then I always set a global flag that I am stopping so as not to attempt more processing while the thread is stopping.

      If at all possible, i would rather stop the process with the hcienginestop command since I know the process will always stop.  This is not necessarily true for a thread if the process is blocked.

    • #62610
      Hope Rolens
      Participant

      Charlie,

      I’m working on a tps pre-proc to stop a process when certain conditions are met.  I want to keep the current message in the recovery database, but haven’t figured out how to do so without creating broken pipes and/or leaked handles in the TPS interpreter.  

      This happens when I use return 0 to exit the proc (after issuing the hcienginestop command).   The only displist I know to return without causing errors is the ERROR $mh.  But I’d rather the message not go to the Error db.

      Any suggestions?

      Thanks,

      Hope Schnelten

      Hospital Sisters Health Systems

    • #62611
      Charlie Bursell
      Participant

      I always call an external script in the background from a TPS procedure.  You never want to KILL yourself.

      I then set a global flag in the TPS script to let me know it is shutting down.  Then just return the empty string for the messages you are working now and any future messages that may come in while you are shutting down.

      Of course you will get a message in the log that says you have unbound messages but you can ignore that.  It should not go to Error DB

    • #62612
      Hope Rolens
      Participant

      Thank you, Charlie.  I appreciate your help!  –Hope

    • #62613
      Hope Rolens
      Participant

      Charlie,

      I’m calling a tcl proc to shut down the process using the system command:

       set stopProc [catch [system hcienginestop -p $process]]

      Then in shutdown mode, a different tcl proc is kicked off in the background to start the process when certain conditions are met:

           shutdown {

              echo “starting shutdown mode”

             # check to see if variable stopProc exists.  If = 1, run proc to monitor dr and start process.  If != 1, shut down as  usual

              if {[info exists stopProc]} {

                 if {$stopProc == “1”} {

                     set stopProc 0

      exec /qdxtest/qdx5.7/integrator/bin/tcl /qdxtest/qdx5.7/integrator/msjsf2/tclprocs/lib/drdb_startProcess.tcl $HciSite $HciProcess $gmsh11 &

                     return “”

                 }

              }

           }

      Everything seems to be working fine — the process stops with the expected error and warning (see end).  

      Echos in the proc that kicks off when the process shuts down continue to write to the process log.  Do you think writing anything to the log after the process has shut down will be problematic ?

      Thanks,    — Hope

      [icl :tcpi:ERR /0:  A59Tphi_cmd:08/02/2010 08:55:43] write failed: Broken pipe

      [prod:prod:INFO/0:     TRphiITS:08/02/2010 08:55:43] Checking for leaked handles in the TPS interpreter…

      Handle     Allocated by

      ======     ============

      message0  

      WARNING: Message [0.0.1104375] is in the RDB and was left bound into Tcl

    • #62614
      Charlie Bursell
      Participant

      If it works for you go for it.  A little strange to call in the shutdown mode since that only executes when the thread is shutdown nicely

Viewing 5 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10