How to use the qsharp.clients.mock.MockClient function in qsharp

To help you get started, we’ve selected a few qsharp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / iqsharp / src / Python / qsharp-core / qsharp / clients / __init__.py View on Github external
def _start_client():
    logger = logging.getLogger(__name__)

    client_name =  os.getenv("QSHARP_PY_CLIENT", "iqsharp")

    if client_name == "iqsharp":
        import qsharp.clients.iqsharp
        client = qsharp.clients.iqsharp.IQSharpClient()
    elif client_name == "mock":
        import qsharp.clients.mock
        client = qsharp.clients.mock.MockClient()
    client.start()

    # Check if the server is up and running:
    server_ready = False
    for idx_attempt in range(20):
        try:
            server_ready = client.is_ready()
            if server_ready:
                break
            if idx_attempt == 0:
                print("Preparing Q# environment...")
            else:
                print(".", end='', flush=True)
            time.sleep(1)
        except Exception as ex:
            logger.debug('Exception while checking Q# environment.', exc_info=ex)