Skip to content

Commit

Permalink
fix blocking issue
Browse files Browse the repository at this point in the history
  • Loading branch information
makemake-kbo committed Jan 8, 2024
1 parent 31a40bb commit ffeb6e6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions hrotti/websocket_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import random
import time
import asyncio

from fastapi import WebSocket

Expand Down Expand Up @@ -42,7 +42,6 @@

# Fakes subscription, sends dummy data every n seconds
async def fake_subscribe(sub_request: RPCRequest, websocket: WebSocket):
print(sub_request)
local_conf = sub_confirmation
id = sub_request.id
local_conf["id"] = id
Expand All @@ -52,7 +51,6 @@ async def fake_subscribe(sub_request: RPCRequest, websocket: WebSocket):
local_conf["result"] = sub_id

# send confirmation and prep our client to listen for subscriptions
print("1")
await websocket.send_json(local_conf)

local_fake_head = fake_new_head
Expand All @@ -63,10 +61,9 @@ async def fake_subscribe(sub_request: RPCRequest, websocket: WebSocket):
while True:
block_num = block_num + 1
local_fake_head["params"]["result"]["number"] = hex(block_num)
print("2")
await websocket.send_json(local_fake_head)
print("3")
time.sleep(6)
await asyncio.sleep(6)
break


# Proceses WS connection
Expand Down

0 comments on commit ffeb6e6

Please sign in to comment.