Changeset 8655


Ignore:
Timestamp:
8 Jun 2012, 15:20:27 (12 years ago)
Author:
uli
Message:

Add function to wait for instance startup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.stress/trunk/src/waeup/stress/__init__.py

    r8654 r8655  
    11import os
     2import socket
    23import subprocess
    34import sys
     5import time
    46import waeup.kofa
    57
     
    7779    return
    7880
     81def wait_for_startup(host, port):
     82    """Wait until a connection to host and port can be made.
     83    """
     84    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     85    while True:
     86        try:
     87            s.connect((host, port))
     88            break
     89        except:
     90            time.sleep(0.1)
     91    s.close()
     92    return
     93
    7994def stop_instance(name):
    8095    path = kofa_projects[name]
Note: See TracChangeset for help on using the changeset viewer.