def __init__(self, name, host='127.0.0.1', port=27017):
        self.name = name
        self.host = host
        self.port = port
def _try_write_with_flush(cls, fileobj, payload):
        """This method is here so that it can be patched to simulate write errors.

        This is because mock can't patch primitive objects like file objects.
        """
        fileobj.write(payload)
        fileobj.flush()