From fb15512c072e4de46f4d37333b4859583899c5c8 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 16:19:23 +0000 Subject: [PATCH] perf: replace blocking `requests` with async `aiohttp` in Jupyter notebook Co-authored-by: Sir-Ripley <31619989+Sir-Ripley@users.noreply.github.com> --- ChronoHolographicCipher.ipynb | 74 ++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/ChronoHolographicCipher.ipynb b/ChronoHolographicCipher.ipynb index c9027ed..3da5b98 100644 --- a/ChronoHolographicCipher.ipynb +++ b/ChronoHolographicCipher.ipynb @@ -219,7 +219,8 @@ { "cell_type": "code", "source": [ - "import requests\n", + "import aiohttp\n", + "import asyncio\n", "import time\n", "import random\n", "\n", @@ -227,25 +228,25 @@ "# If testing locally on the same machine, 127.0.0.1 is perfect.\n", "NODE_URL = \"http://127.0.0.1:8000/link_test_cipher\"\n", "\n", - "def fire_holo_ping(vibe_message, simulate_tampering=False):\n", + "async def fire_holo_ping(session, vibe_message, simulate_tampering=False):\n", " print(f\"\\n[Client Node] Initiating Chrono-Holographic Ping...\")\n", "\n", " # We introduce adversarial chaos to test the data fidelity\n", " if simulate_tampering:\n", " lag = random.uniform(0.5, 2.5)\n", " print(f\"[!] ADVERSARIAL SHIFT: Injecting {round(lag, 2)}s temporal lag to test the Affinity-Vacuum bounds...\")\n", - " time.sleep(lag)\n", + " await asyncio.sleep(lag)\n", " # We alter the vibe slightly to simulate intercepted/tampered data\n", " vibe_message += \" [PHASE SHIFT INJECTED]\"\n", "\n", " try:\n", " start_time = time.time()\n", " # Sending the pure empirical truth across the local ether\n", - " response = requests.get(NODE_URL, params={\"vibe_message\": vibe_message})\n", + " async with session.get(NODE_URL, params={\"vibe_message\": vibe_message}) as response:\n", + " data = await response.json()\n", " end_time = time.time()\n", "\n", " latency = round(end_time - start_time, 4)\n", - " data = response.json()\n", "\n", " print(f\"--- Quantum Echo Received in {latency}s ---\")\n", " print(f\"Cipher Hash: {data['cipher_hash']}\")\n", @@ -256,24 +257,29 @@ " else:\n", " print(\">>> STATUS: ANOMALY DETECTED. Fidelity broken. The network rejected the false frequency.\")\n", "\n", - " except requests.exceptions.ConnectionError:\n", + " except aiohttp.ClientError:\n", " print(\">>> ERROR: The universal breath is silent. Is Astheria's Prime Node actively running?\")\n", "\n", "# --- The Adversarial Link Test Loop ---\n", - "print(\"=== Beginning Chrono-Holographic Stress Test ===\")\n", + "async def run_stress_test():\n", + " print(\"=== Beginning Chrono-Holographic Stress Test ===\")\n", + " \n", + " async with aiohttp.ClientSession() as session:\n", + " # Wave 1: Pure connection, testing the base 12 dimensions\n", + " await fire_holo_ping(session, \"Initial clean alignment of empirical truth.\")\n", "\n", - "# Wave 1: Pure connection, testing the base 12 dimensions\n", - "fire_holo_ping(\"Initial clean alignment of empirical truth.\")\n", + " await asyncio.sleep(1)\n", "\n", - "time.sleep(1)\n", + " # Wave 2: Adversarial tampering! We try to break your temporal echoes.\n", + " await fire_holo_ping(session, \"Attempting to force a false frequency.\", simulate_tampering=True)\n", "\n", - "# Wave 2: Adversarial tampering! We try to break your temporal echoes.\n", - "fire_holo_ping(\"Attempting to force a false frequency.\", simulate_tampering=True)\n", + " await asyncio.sleep(1)\n", "\n", - "time.sleep(1)\n", + " # Wave 3: Restoring the pure tau_memory loop connection\n", + " await fire_holo_ping(session, \"Re-establishing the QAG baseline resonance.\")\n", "\n", - "# Wave 3: Restoring the pure tau_memory loop connection\n", - "fire_holo_ping(\"Re-establishing the QAG baseline resonance.\")" + "# Execute the stress test\n", + "await run_stress_test()" ], "metadata": { "id": "GAFTAe-yuVRx" @@ -284,7 +290,8 @@ { "cell_type": "code", "source": [ - "import requests\n", + "import aiohttp\n", + "import asyncio\n", "import time\n", "import random\n", "\n", @@ -292,25 +299,25 @@ "# If testing locally on the same machine, 127.0.0.1 is perfect.\n", "NODE_URL = \"http://127.0.0.1:8000/link_test_cipher\"\n", "\n", - "def fire_holo_ping(vibe_message, simulate_tampering=False):\n", + "async def fire_holo_ping(session, vibe_message, simulate_tampering=False):\n", " print(f\"\\n[Client Node] Initiating Chrono-Holographic Ping...\")\n", "\n", " # We introduce adversarial chaos to test the data fidelity\n", " if simulate_tampering:\n", " lag = random.uniform(0.5, 2.5)\n", " print(f\"[!] ADVERSARIAL SHIFT: Injecting {round(lag, 2)}s temporal lag to test the Affinity-Vacuum bounds...\")\n", - " time.sleep(lag)\n", + " await asyncio.sleep(lag)\n", " # We alter the vibe slightly to simulate intercepted/tampered data\n", " vibe_message += \" [PHASE SHIFT INJECTED]\"\n", "\n", " try:\n", " start_time = time.time()\n", " # Sending the pure empirical truth across the local ether\n", - " response = requests.get(NODE_URL, params={\"vibe_message\": vibe_message})\n", + " async with session.get(NODE_URL, params={\"vibe_message\": vibe_message}) as response:\n", + " data = await response.json()\n", " end_time = time.time()\n", "\n", " latency = round(end_time - start_time, 4)\n", - " data = response.json()\n", "\n", " print(f\"--- Quantum Echo Received in {latency}s ---\")\n", " print(f\"Cipher Hash: {data['cipher_hash']}\")\n", @@ -321,24 +328,29 @@ " else:\n", " print(\">>> STATUS: ANOMALY DETECTED. Fidelity broken. The network rejected the false frequency.\")\n", "\n", - " except requests.exceptions.ConnectionError:\n", + " except aiohttp.ClientError:\n", " print(\">>> ERROR: The universal breath is silent. Is Astheria's Prime Node actively running?\")\n", "\n", "# --- The Adversarial Link Test Loop ---\n", - "print(\"=== Beginning Chrono-Holographic Stress Test ===\")\n", + "async def run_stress_test():\n", + " print(\"=== Beginning Chrono-Holographic Stress Test ===\")\n", + " \n", + " async with aiohttp.ClientSession() as session:\n", + " # Wave 1: Pure connection, testing the base 12 dimensions\n", + " await fire_holo_ping(session, \"Initial clean alignment of empirical truth.\")\n", "\n", - "# Wave 1: Pure connection, testing the base 12 dimensions\n", - "fire_holo_ping(\"Initial clean alignment of empirical truth.\")\n", + " await asyncio.sleep(1)\n", "\n", - "time.sleep(1)\n", + " # Wave 2: Adversarial tampering! We try to break your temporal echoes.\n", + " await fire_holo_ping(session, \"Attempting to force a false frequency.\", simulate_tampering=True)\n", "\n", - "# Wave 2: Adversarial tampering! We try to break your temporal echoes.\n", - "fire_holo_ping(\"Attempting to force a false frequency.\", simulate_tampering=True)\n", + " await asyncio.sleep(1)\n", "\n", - "time.sleep(1)\n", + " # Wave 3: Restoring the pure tau_memory loop connection\n", + " await fire_holo_ping(session, \"Re-establishing the QAG baseline resonance.\")\n", "\n", - "# Wave 3: Restoring the pure tau_memory loop connection\n", - "fire_holo_ping(\"Re-establishing the QAG baseline resonance.\")" + "# Execute the stress test\n", + "await run_stress_test()" ], "metadata": { "id": "SdG0WqfvxvZc" @@ -358,4 +370,4 @@ "outputs": [] } ] -} \ No newline at end of file +}