def get_mongo_client(host, port=27017):
 def create_mongo_client():
  try:
   client = MongoClient(host=host, port=port)
   client.areyoualive.posts.insert({'ping': 1})
   return client
  except PyMongoError:
   return False
 d = loop_until(reactor, create_mongo_client)
 return d

def get_mongo_client ( host , port = 27017 ) : def create_mongo_client ( ) : try : client = MongoClient ( host = host , port = port ) client . areyoualive . posts . insert ( { 'ping' : 1 } ) return client except PyMongoError : return False d = loop_until ( reactor , create_mongo_client ) return d
returns a deferred which fires with a mongoclient when one has been created .