This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| retcode = p.poll() # Check on the application | |
| if retcode is not None: # The application exited | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| end_time = time.time() + 2 * g_TO | |
| all_is_well = True | |
| missed_TO = 0 | |
| while True: | |
| try: | |
| (r, w, e) = zmq.select([in_hb, in_cmd], [], [], timeout=end_time - time.time()) | |
| for sock in r: | |
| msg = sock.recv() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| (r, w, e) = zmq.select([in_hb, in_cmd], [], [], timeout=end_time - time.time()) | |
| for sock in r: | |
| msg = sock.recv() | |
| # ... | |
| if sock == in_cmd: | |
| print '[monitor] Order to execute' | |
| all_is_well = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| retcode = 1 | |
| while retcode: | |
| retcode = subprocess.call(["lolprogram", "arg1", "arg2"]) | |
| print("Exiting with return code 0") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 'p' is the Popen object for the subprocess. | |
| end_time = time.time() + 2 * g_TO # Time to initialize | |
| all_is_well = True | |
| missed_TO = 0 | |
| while True: | |
| try: | |
| (r, w, e) = zmq.select( | |
| [in_hb, in_cmd], [], [], timeout=end_time - time.time()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 'p' is the Popen object for the subprocess | |
| all_is_well = True | |
| while True: | |
| try: | |
| (r, w, e) = zmq.select( | |
| [in_hb, in_cmd], [], [], timeout=end_time - time.time()) | |
| for sock in r: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test <- function() { | |
| return(c(1,2,3)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StdDevCalc { | |
| private: | |
| long long m_count; | |
| double m_sum_sq, m_sum, m_var; | |
| public: | |
| StdDevCalc() { | |
| m_sum_sq = m_sum = m_var = m_count = 0; | |
| } | |
| void append(double d) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StdDevCalcKnuth { | |
| private: | |
| long long m_count; | |
| double m_meanPrev, m_meanCurr, m_sPrev, m_sCurr, m_varianceCurr; | |
| public: | |
| StdDevCalcKnuth() { | |
| m_count = 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() { | |
| StdDevCalc c, c2; | |
| StdDevCalcKnuth k, k2; | |
| for(int i = 0; i < 100; i++) { | |
| c.append(i); // Small values | |
| k.append(i); | |
| c2.append((double) i * 3e151); // Very very large values | |
| k2.append((double) i * 3e151); |
OlderNewer