Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I followed your advice. Starting the thread also caused my PSSE instance to hang. There wasn't any error message, but the program never finished.

I changed the program so that there were no sleep statements at all, so it should have finished very quickly, but still PSSE wasn't able to run the program to completion. It just becomes non-responsive.

It may be that you are unable to run threads from inside of the PSSE program. Here is how to run a loadflow inside a thread, from outside of PSSE.

import sys
import os
import threading
import time


PSSE_LOCATION = r'c:/program files/pti/psse32/pssbin'
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] += ';' + PSSE_LOCATION

import psspy
psspy.throwPsseExceptions = True

class RunLoadflow(threading.Thread):
    def __init__(self, savefilename):
        super(RunLoadflow, self).__init__()
        self.casename = savefilename

    def run(self):
        psspy.case(self.casename)
        psspy.fnsl()

psspy.psseinit(8000)
CASENAME = r"c:/program files/pti/psse32/example/savnw.sav"
thread = RunLoadflow(CASENAME)
thread.start()
thread.join()

This might help you restructure your Python code so that it runs outside of the PSSE program.