diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-11 17:17:36 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-11 17:17:36 -0500 |
commit | 5d44f01b1fb59093878d323f1ea254fdcf9301eb (patch) | |
tree | e35f268f15ca2974d02d466c9e35497301cf5eb7 /buildscripts | |
parent | e13c189def565b7cb1b3ac1e02655eb218c2c174 (diff) | |
download | mongo-5d44f01b1fb59093878d323f1ea254fdcf9301eb.tar.gz |
wait longer but smarter for mongod to stasrt
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/buildscripts/utils.py b/buildscripts/utils.py index 06b7fa3c687..41d676740af 100644 --- a/buildscripts/utils.py +++ b/buildscripts/utils.py @@ -1,5 +1,7 @@ import re +import socket +import time # various utilities that are handy @@ -21,3 +23,25 @@ def getprocesslist(): r = re.compile( "[\r\n]+" ) return r.split( raw ) + + +def checkMongoPort( port=27017 ): + sock = socket.socket() + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + sock.settimeout(1) + sock.connect(("localhost", port)) + sock.close() + +def didMongodStart( port=27017 , timeout=20 ): + while timeout > 0: + time.sleep( 1 ) + try: + checkMongoPort( port ) + return True + except Exception,e: + print( e ) + timeout = timeout - 1 + + return False + + |