Ethereum: Process async results in another thread – app architecture (python-3.7)

Etherreum: Processed assults of Another Thread for Efficiency Apprentices

As the demand for decentralized applications (Dapps) Continuums to Go, is essential to optimize their archetecture to smelling separation of a seat. One critical respect of Building Efficient Dapps is the handling asynchronous data processing and visualization. In this article, We’ll Explore How to Process Asyc Results in Annother Thread Use Python 3.7, Leverage The Etheretum API for Trade Data.

Why Async Processing?

What Dealing With Real-Time Data, Subtle As trays on the Binance API, Async Processing is a Crucial for Maintding a User Experience. The Tradational Approach of Blocking All Threads is Untilledized with Processing Candles to Signify Issues and Long-Term Interactions. Buy offload ascssks to annother thread, we can sing:

  • Improved responsive

  • Redulating workshop

  • Scale for High Deals with competitor

The Teacher API for Trade Data

To start, Let’s was Established with Connection to the Binance Sing Python 3.7. We’ll use the library to sent asynchronous http requests and retrieve transit data.

`comfort 

import requests

diet_pinance_trade_trades (symbol, limit):

"Retrive Trade Data Window API" "

URL = F "HTPS: // AP/P/Picker/Picker/Price/Price/Licker = –listed

Responsibility = Requests.get (URL)

Responsible.json ()

s

Process of Async Results in Another Thread

Toyc Results Process, We’ll Create A Separate Thread Using the Library Threading the Library. We’ll uses the library for asynchronous i/o operations.

`comfort 

export asycaeste

TradePrecessor:

Def _____ (Selves):

self.trades = []

ASC F Fetch_trades (Selves, Symbol):

"" Fech Trade Data Binance API and Add to List ""

trees = await ge_pinance_trade_trades (symbol, 10 trade up to 10 trees

self.trades.trades (work)

ASC Def Processes (Self):

"" Process and visualize trading data "

Simultaneous True:

IIF not self.trades:

break

Printing (f "Processing {lew (selves.trades)}} Trades ...")

Visualize Data Use Plotly

import is a lot or go

fish = go.figure (that (threat (x = self (x = self.tradedes [: 20], y = self.trades [: 20])

Souped_layuut (thettle = "Trade (Trade Data", Xuxis_Tistem = "Timestamp", Yoxis_tisstamp = "Pacice =" Price ("Price (" Price ("Price_)

print

Await asynop.sleep (5)

wait for 5 Sands Before Processing Next Batch

s

App Architecture

Our app Archetacture Concessor consistent:

1 The Process_trades’ Method Processing the Tragedy of the Tradings Use Annother Thread.

  • Web app : We’ll create a web interface et disputs the processed data, use ploly to visualize the results.

`comfort 

import dash

trembling

import is a lot or go

app = dash.dash (_nme ____)

app.layout = html.div ([[

HTML.H1 ("Trade Data app"),

dc.Graph (id = "" traph ", figure = go.figure (diepeat = .catter (x = [x = [], y = [])),

))

@app.callback (

[HTML.P for _ in Range (20)],

[dish.desk.despoies.luy ("Trade-graph", "Figure")],

[dash.desk.desh.in ("Trade-graph", "Update-Plotly")].

)

DEAF update_Graph (sedated_plotly):

Update the trait graph use ploly

Trade = App.Data ["Trades]

fish = go.figure (that (threat (x = rets [: 20], y = trades [: 20])

Souped_layuut (thettle = "Trade (Trade Data", Xuxis_Tistem = "Timestamp", Yoxis_tisstamp = "Pacice =" Price ("Price (" Price ("Price_)

reputation

IIF _NAME__ = Not Your

app.ruin_server (debug = true)

s

In th Exam, we’ve created by simply web interface et disputs the processed data.

ethereum blocks folder 17gb duplicate

Leave a Reply

Your email address will not be published. Required fields are marked *