Example #1
0
	def _pstatsToggle(self):
		print("HI")
		if self._pstatProc:
			# TODO: Fix this. It does not terminate the pstats process.
			print("Terminating pstats pid=%s"%(self._pstatProc.pid))
			PStatClient.disconnect()
			self._pstatProc.terminate()
			time.sleep(2)
			#self._pstatProc.kill()
			#self._pstatProc.send_signal(signal.SIGTERM)
			#os.kill( self._pstatProc.pid , signal.SIGTERM)
		else:
			print("Starting pstats server")
			self._pstatProc = subprocess.Popen("pstats", shell=True)
			print("  pstats proc: pid=%s"%(self._pstatProc.pid))
			time.sleep(1)
			print("Connecting to pstats server")
			PStatClient.connect()