import{S as Js,i as Qs,s as Ks,e as n,k as h,w as y,t as l,M as Xs,c as r,d as t,m as u,a as i,x as w,h as p,b as c,G as s,g as o,y as g,q as v,o as b,B as k,v as Vs}from"../chunks/vendor-hf-doc-builder.js";import{T as Fs}from"../chunks/Tip-hf-doc-builder.js";import{I as me}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as vt}from"../chunks/CodeBlock-hf-doc-builder.js";function Ys(Y){let f;return{c(){f=l(`Creating an inference engine is a complex topic, and the "best" solution 
will most likely depend on your problem space. Are you on CPU or GPU? Do
you want the lowest latency, the highest throughput, support for
many models, or just highly optimize 1 specific model?
There are many ways to tackle this topic, so what we are going to present is a good default
to get started which may not necessarily be the most optimal solution for you.`)},l(m){f=p(m,`Creating an inference engine is a complex topic, and the "best" solution 
will most likely depend on your problem space. Are you on CPU or GPU? Do
you want the lowest latency, the highest throughput, support for
many models, or just highly optimize 1 specific model?
There are many ways to tackle this topic, so what we are going to present is a good default
to get started which may not necessarily be the most optimal solution for you.`)},m(m,d){o(m,f,d)},d(m){m&&t(f)}}}function Zs(Y){let f;return{c(){f=l("Do not activate this without checking it makes sense for your load!")},l(m){f=p(m,"Do not activate this without checking it makes sense for your load!")},m(m,d){o(m,f,d)},d(m){m&&t(f)}}}function ea(Y){let f,m,d,T,de,U,bt,ye,kt,Ce,A,Oe,S,$t,Z,qt,_t,Be,ee,jt,Re,x,Et,we,Pt,Tt,ze,N,At,ge,St,xt,Ie,G,Me,te,Nt,De,H,Ue,se,Ct,Ge,L,He,ae,Ot,Le,C,Bt,ve,Rt,zt,We,W,Fe,O,Je,oe,It,Qe,ne,Mt,Ke,re,Dt,Xe,q,B,be,F,Ut,ke,Gt,Ve,_,R,$e,J,Ht,qe,Lt,Ye,ie,Wt,Ze,z,Ft,_e,Jt,Qt,et,j,I,je,Q,Kt,Ee,Xt,tt,le,Vt,st,pe,Yt,at,E,M,Pe,K,Zt,Te,es,ot,he,ts,nt,ue,ss,rt,P,D,Ae,X,as,Se,os,it,$,ns,ce,rs,is,xe,ls,ps,lt;return U=new me({}),A=new Fs({props:{$$slots:{default:[Ys]},$$scope:{ctx:Y}}}),G=new vt({props:{code:`from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
from transformers import pipeline
import asyncio


async def homepage(request):
    payload = await request.body()
    string = payload.decode("utf-8")
    response_q = asyncio.Queue()
    await request.app.model_queue.put((string, response_q))
    output = await response_q.get()
    return JSONResponse(output)


async def server_loop(q):
    pipe = pipeline(model="bert-base-uncased")
    while True:
        (string, response_q) = await q.get()
        out = pipe(string)
        await response_q.put(out)


app = Starlette(
    routes=[
        Route("/", homepage, methods=["POST"]),
    ],
)


@app.on_event("startup")
async def startup_event():
    q = asyncio.Queue()
    app.model_queue = q
    asyncio.create_task(server_loop(q))`,highlighted:`<span class="hljs-keyword">from</span> starlette.applications <span class="hljs-keyword">import</span> Starlette
<span class="hljs-keyword">from</span> starlette.responses <span class="hljs-keyword">import</span> JSONResponse
<span class="hljs-keyword">from</span> starlette.routing <span class="hljs-keyword">import</span> Route
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline
<span class="hljs-keyword">import</span> asyncio


<span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">homepage</span>(<span class="hljs-params">request</span>):
    payload = <span class="hljs-keyword">await</span> request.body()
    string = payload.decode(<span class="hljs-string">&quot;utf-8&quot;</span>)
    response_q = asyncio.Queue()
    <span class="hljs-keyword">await</span> request.app.model_queue.put((string, response_q))
    output = <span class="hljs-keyword">await</span> response_q.get()
    <span class="hljs-keyword">return</span> JSONResponse(output)


<span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">server_loop</span>(<span class="hljs-params">q</span>):
    pipe = pipeline(model=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
        (string, response_q) = <span class="hljs-keyword">await</span> q.get()
        out = pipe(string)
        <span class="hljs-keyword">await</span> response_q.put(out)


app = Starlette(
    routes=[
        Route(<span class="hljs-string">&quot;/&quot;</span>, homepage, methods=[<span class="hljs-string">&quot;POST&quot;</span>]),
    ],
)


<span class="hljs-meta">@app.on_event(<span class="hljs-params"><span class="hljs-string">&quot;startup&quot;</span></span>)</span>
<span class="hljs-keyword">async</span> <span class="hljs-keyword">def</span> <span class="hljs-title function_">startup_event</span>():
    q = asyncio.Queue()
    app.model_queue = q
    asyncio.create_task(server_loop(q))`}}),H=new vt({props:{code:"uvicorn server:app",highlighted:"uvicorn server:app"}}),L=new vt({props:{code:`curl -X POST -d "test [MASK]" http://localhost:8000/
#[{"score":0.7742936015129089,"token":1012,"token_str":".","sequence":"test."},...]`,highlighted:`curl -X POST -d <span class="hljs-string">&quot;test [MASK]&quot;</span> http://localhost:8000/
<span class="hljs-comment">#[{&quot;score&quot;:0.7742936015129089,&quot;token&quot;:1012,&quot;token_str&quot;:&quot;.&quot;,&quot;sequence&quot;:&quot;test.&quot;},...]</span>`}}),W=new vt({props:{code:`(string, rq) = await q.get()
strings = []
queues = []
while True:
    try:
        (string, rq) = await asyncio.wait_for(q.get(), timeout=0.001)  # 1ms
    except asyncio.exceptions.TimeoutError:
        break
    strings.append(string)
    queues.append(rq)
strings
outs = pipe(strings, batch_size=len(strings))
for (rq, out) in zip(queues, outs):
    await rq.put(out)`,highlighted:`(string, rq) = <span class="hljs-keyword">await</span> q.get()
strings = []
queues = []
<span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
    <span class="hljs-keyword">try</span>:
        (string, rq) = <span class="hljs-keyword">await</span> asyncio.wait_for(q.get(), timeout=<span class="hljs-number">0.001</span>)  <span class="hljs-comment"># 1ms</span>
    <span class="hljs-keyword">except</span> asyncio.exceptions.TimeoutError:
        <span class="hljs-keyword">break</span>
    strings.append(string)
    queues.append(rq)
strings
outs = pipe(strings, batch_size=<span class="hljs-built_in">len</span>(strings))
<span class="hljs-keyword">for</span> (rq, out) <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(queues, outs):
    <span class="hljs-keyword">await</span> rq.put(out)`}}),O=new Fs({props:{warning:!0,$$slots:{default:[Zs]},$$scope:{ctx:Y}}}),F=new me({}),J=new me({}),Q=new me({}),K=new me({}),X=new me({}),{c(){f=n("meta"),m=h(),d=n("h1"),T=n("a"),de=n("span"),y(U.$$.fragment),bt=h(),ye=n("span"),kt=l("Using pipelines for a webserver"),Ce=h(),y(A.$$.fragment),Oe=h(),S=n("p"),$t=l("The key thing to understand is that we can use an iterator, just like you would "),Z=n("a"),qt=l(`on a
dataset`),_t=l(`, since a webserver is basically a system that waits for requests and
treats them as they come in.`),Be=h(),ee=n("p"),jt=l(`Usually webservers are multiplexed (multithreaded, async, etc..) to handle various
requests concurrently. Pipelines on the other hand (and mostly the underlying models)
are not really great for parallelism; they take up a lot of RAM, so it\u2019s best to give them all the available resources when they are running or it\u2019s a compute-intensive job.`),Re=h(),x=n("p"),Et=l(`We are going to solve that by having the webserver handle the light load of receiving
and sending requests, and having a single thread handling the actual work.
This example is going to use `),we=n("code"),Pt=l("starlette"),Tt=l(`. The actual framework is not really
important, but you might have to tune or change the code if you are using another
one to achieve the same effect.`),ze=h(),N=n("p"),At=l("Create "),ge=n("code"),St=l("server.py"),xt=l(":"),Ie=h(),y(G.$$.fragment),Me=h(),te=n("p"),Nt=l("Now you can start it with:"),De=h(),y(H.$$.fragment),Ue=h(),se=n("p"),Ct=l("And you can query it:"),Ge=h(),y(L.$$.fragment),He=h(),ae=n("p"),Ot=l("And there you go, now you have a good idea of how to create a webserver!"),Le=h(),C=n("p"),Bt=l("What is really important is that we load the model only "),ve=n("strong"),Rt=l("once"),zt=l(`, so there are no copies
of the model on the webserver. This way, no unnecessary RAM is being used.
Then the queuing mechanism allows you to do fancy stuff like maybe accumulating a few
items before inferring to use dynamic batching:`),We=h(),y(W.$$.fragment),Fe=h(),y(O.$$.fragment),Je=h(),oe=n("p"),It=l(`The proposed code is optimized for readability, not for being the best code.
First of all, there\u2019s no batch size limit which is usually not a
great idea. Next, the timeout is reset on every queue fetch, meaning you could
wait much more than 1ms before running the inference (delaying the first request
by that much).`),Qe=h(),ne=n("p"),Mt=l("It would be better to have a single 1ms deadline."),Ke=h(),re=n("p"),Dt=l(`This will always wait for 1ms even if the queue is empty, which might not be the
best since you probably want to start doing inference if there\u2019s nothing in the queue.
But maybe it does make sense if batching is really crucial for your use case.
Again, there\u2019s really no one best solution.`),Xe=h(),q=n("h2"),B=n("a"),be=n("span"),y(F.$$.fragment),Ut=h(),ke=n("span"),Gt=l("Few things you might want to consider"),Ve=h(),_=n("h3"),R=n("a"),$e=n("span"),y(J.$$.fragment),Ht=h(),qe=n("span"),Lt=l("Error checking"),Ye=h(),ie=n("p"),Wt=l(`There\u2019s a lot that can go wrong in production: out of memory, out of space,
loading the model might fail, the query might be wrong, the query might be
correct but still fail to run because of a model misconfiguration, and so on.`),Ze=h(),z=n("p"),Ft=l(`Generally, it\u2019s good if the server outputs the errors to the user, so
adding a lot of `),_e=n("code"),Jt=l("try..except"),Qt=l(` statements to show those errors is a good
idea. But keep in mind it may also be a security risk to reveal all those errors depending
on your security context.`),et=h(),j=n("h3"),I=n("a"),je=n("span"),y(Q.$$.fragment),Kt=h(),Ee=n("span"),Xt=l("Circuit breaking"),tt=h(),le=n("p"),Vt=l(`Webservers usually look better when they do circuit breaking. It means they
return proper errors when they\u2019re overloaded instead of just waiting for the query indefinitely. Return a 503 error instead of waiting for a super long time or a 504 after a long time.`),st=h(),pe=n("p"),Yt=l(`This is relatively easy to implement in the proposed code since there is a single queue.
Looking at the queue size is a basic way to start returning errors before your
webserver fails under load.`),at=h(),E=n("h3"),M=n("a"),Pe=n("span"),y(K.$$.fragment),Zt=h(),Te=n("span"),es=l("Blocking the main thread"),ot=h(),he=n("p"),ts=l(`Currently PyTorch is not async aware, and computation will block the main
thread while running. That means it would be better if PyTorch was forced to run
on its own thread/process. This wasn\u2019t done here because the code is a lot more
complex (mostly because threads and async and queues don\u2019t play nice together).
But ultimately it does the same thing.`),nt=h(),ue=n("p"),ss=l(`This would be important if the inference of single items were long (> 1s) because
in this case, it means every query during inference would have to wait for 1s before
even receiving an error.`),rt=h(),P=n("h3"),D=n("a"),Ae=n("span"),y(X.$$.fragment),as=h(),Se=n("span"),os=l("Dynamic batching"),it=h(),$=n("p"),ns=l(`In general, batching is not necessarily an improvement over passing 1 item at
a time (see `),ce=n("a"),rs=l("batching details"),is=l(` for more information). But it can be very effective
when used in the correct setting. In the API, there is no dynamic
batching by default (too much opportunity for a slowdown). But for BLOOM inference -
which is a very large model - dynamic batching is `),xe=n("strong"),ls=l("essential"),ps=l(" to provide a decent experience for everyone."),this.h()},l(e){const a=Xs('[data-svelte="svelte-1phssyn"]',document.head);f=r(a,"META",{name:!0,content:!0}),a.forEach(t),m=u(e),d=r(e,"H1",{class:!0});var V=i(d);T=r(V,"A",{id:!0,class:!0,href:!0});var Ne=i(T);de=r(Ne,"SPAN",{});var hs=i(de);w(U.$$.fragment,hs),hs.forEach(t),Ne.forEach(t),bt=u(V),ye=r(V,"SPAN",{});var us=i(ye);kt=p(us,"Using pipelines for a webserver"),us.forEach(t),V.forEach(t),Ce=u(e),w(A.$$.fragment,e),Oe=u(e),S=r(e,"P",{});var pt=i(S);$t=p(pt,"The key thing to understand is that we can use an iterator, just like you would "),Z=r(pt,"A",{href:!0});var cs=i(Z);qt=p(cs,`on a
dataset`),cs.forEach(t),_t=p(pt,`, since a webserver is basically a system that waits for requests and
treats them as they come in.`),pt.forEach(t),Be=u(e),ee=r(e,"P",{});var fs=i(ee);jt=p(fs,`Usually webservers are multiplexed (multithreaded, async, etc..) to handle various
requests concurrently. Pipelines on the other hand (and mostly the underlying models)
are not really great for parallelism; they take up a lot of RAM, so it\u2019s best to give them all the available resources when they are running or it\u2019s a compute-intensive job.`),fs.forEach(t),Re=u(e),x=r(e,"P",{});var ht=i(x);Et=p(ht,`We are going to solve that by having the webserver handle the light load of receiving
and sending requests, and having a single thread handling the actual work.
This example is going to use `),we=r(ht,"CODE",{});var ms=i(we);Pt=p(ms,"starlette"),ms.forEach(t),Tt=p(ht,`. The actual framework is not really
important, but you might have to tune or change the code if you are using another
one to achieve the same effect.`),ht.forEach(t),ze=u(e),N=r(e,"P",{});var ut=i(N);At=p(ut,"Create "),ge=r(ut,"CODE",{});var ds=i(ge);St=p(ds,"server.py"),ds.forEach(t),xt=p(ut,":"),ut.forEach(t),Ie=u(e),w(G.$$.fragment,e),Me=u(e),te=r(e,"P",{});var ys=i(te);Nt=p(ys,"Now you can start it with:"),ys.forEach(t),De=u(e),w(H.$$.fragment,e),Ue=u(e),se=r(e,"P",{});var ws=i(se);Ct=p(ws,"And you can query it:"),ws.forEach(t),Ge=u(e),w(L.$$.fragment,e),He=u(e),ae=r(e,"P",{});var gs=i(ae);Ot=p(gs,"And there you go, now you have a good idea of how to create a webserver!"),gs.forEach(t),Le=u(e),C=r(e,"P",{});var ct=i(C);Bt=p(ct,"What is really important is that we load the model only "),ve=r(ct,"STRONG",{});var vs=i(ve);Rt=p(vs,"once"),vs.forEach(t),zt=p(ct,`, so there are no copies
of the model on the webserver. This way, no unnecessary RAM is being used.
Then the queuing mechanism allows you to do fancy stuff like maybe accumulating a few
items before inferring to use dynamic batching:`),ct.forEach(t),We=u(e),w(W.$$.fragment,e),Fe=u(e),w(O.$$.fragment,e),Je=u(e),oe=r(e,"P",{});var bs=i(oe);It=p(bs,`The proposed code is optimized for readability, not for being the best code.
First of all, there\u2019s no batch size limit which is usually not a
great idea. Next, the timeout is reset on every queue fetch, meaning you could
wait much more than 1ms before running the inference (delaying the first request
by that much).`),bs.forEach(t),Qe=u(e),ne=r(e,"P",{});var ks=i(ne);Mt=p(ks,"It would be better to have a single 1ms deadline."),ks.forEach(t),Ke=u(e),re=r(e,"P",{});var $s=i(re);Dt=p($s,`This will always wait for 1ms even if the queue is empty, which might not be the
best since you probably want to start doing inference if there\u2019s nothing in the queue.
But maybe it does make sense if batching is really crucial for your use case.
Again, there\u2019s really no one best solution.`),$s.forEach(t),Xe=u(e),q=r(e,"H2",{class:!0});var ft=i(q);B=r(ft,"A",{id:!0,class:!0,href:!0});var qs=i(B);be=r(qs,"SPAN",{});var _s=i(be);w(F.$$.fragment,_s),_s.forEach(t),qs.forEach(t),Ut=u(ft),ke=r(ft,"SPAN",{});var js=i(ke);Gt=p(js,"Few things you might want to consider"),js.forEach(t),ft.forEach(t),Ve=u(e),_=r(e,"H3",{class:!0});var mt=i(_);R=r(mt,"A",{id:!0,class:!0,href:!0});var Es=i(R);$e=r(Es,"SPAN",{});var Ps=i($e);w(J.$$.fragment,Ps),Ps.forEach(t),Es.forEach(t),Ht=u(mt),qe=r(mt,"SPAN",{});var Ts=i(qe);Lt=p(Ts,"Error checking"),Ts.forEach(t),mt.forEach(t),Ye=u(e),ie=r(e,"P",{});var As=i(ie);Wt=p(As,`There\u2019s a lot that can go wrong in production: out of memory, out of space,
loading the model might fail, the query might be wrong, the query might be
correct but still fail to run because of a model misconfiguration, and so on.`),As.forEach(t),Ze=u(e),z=r(e,"P",{});var dt=i(z);Ft=p(dt,`Generally, it\u2019s good if the server outputs the errors to the user, so
adding a lot of `),_e=r(dt,"CODE",{});var Ss=i(_e);Jt=p(Ss,"try..except"),Ss.forEach(t),Qt=p(dt,` statements to show those errors is a good
idea. But keep in mind it may also be a security risk to reveal all those errors depending
on your security context.`),dt.forEach(t),et=u(e),j=r(e,"H3",{class:!0});var yt=i(j);I=r(yt,"A",{id:!0,class:!0,href:!0});var xs=i(I);je=r(xs,"SPAN",{});var Ns=i(je);w(Q.$$.fragment,Ns),Ns.forEach(t),xs.forEach(t),Kt=u(yt),Ee=r(yt,"SPAN",{});var Cs=i(Ee);Xt=p(Cs,"Circuit breaking"),Cs.forEach(t),yt.forEach(t),tt=u(e),le=r(e,"P",{});var Os=i(le);Vt=p(Os,`Webservers usually look better when they do circuit breaking. It means they
return proper errors when they\u2019re overloaded instead of just waiting for the query indefinitely. Return a 503 error instead of waiting for a super long time or a 504 after a long time.`),Os.forEach(t),st=u(e),pe=r(e,"P",{});var Bs=i(pe);Yt=p(Bs,`This is relatively easy to implement in the proposed code since there is a single queue.
Looking at the queue size is a basic way to start returning errors before your
webserver fails under load.`),Bs.forEach(t),at=u(e),E=r(e,"H3",{class:!0});var wt=i(E);M=r(wt,"A",{id:!0,class:!0,href:!0});var Rs=i(M);Pe=r(Rs,"SPAN",{});var zs=i(Pe);w(K.$$.fragment,zs),zs.forEach(t),Rs.forEach(t),Zt=u(wt),Te=r(wt,"SPAN",{});var Is=i(Te);es=p(Is,"Blocking the main thread"),Is.forEach(t),wt.forEach(t),ot=u(e),he=r(e,"P",{});var Ms=i(he);ts=p(Ms,`Currently PyTorch is not async aware, and computation will block the main
thread while running. That means it would be better if PyTorch was forced to run
on its own thread/process. This wasn\u2019t done here because the code is a lot more
complex (mostly because threads and async and queues don\u2019t play nice together).
But ultimately it does the same thing.`),Ms.forEach(t),nt=u(e),ue=r(e,"P",{});var Ds=i(ue);ss=p(Ds,`This would be important if the inference of single items were long (> 1s) because
in this case, it means every query during inference would have to wait for 1s before
even receiving an error.`),Ds.forEach(t),rt=u(e),P=r(e,"H3",{class:!0});var gt=i(P);D=r(gt,"A",{id:!0,class:!0,href:!0});var Us=i(D);Ae=r(Us,"SPAN",{});var Gs=i(Ae);w(X.$$.fragment,Gs),Gs.forEach(t),Us.forEach(t),as=u(gt),Se=r(gt,"SPAN",{});var Hs=i(Se);os=p(Hs,"Dynamic batching"),Hs.forEach(t),gt.forEach(t),it=u(e),$=r(e,"P",{});var fe=i($);ns=p(fe,`In general, batching is not necessarily an improvement over passing 1 item at
a time (see `),ce=r(fe,"A",{href:!0});var Ls=i(ce);rs=p(Ls,"batching details"),Ls.forEach(t),is=p(fe,` for more information). But it can be very effective
when used in the correct setting. In the API, there is no dynamic
batching by default (too much opportunity for a slowdown). But for BLOOM inference -
which is a very large model - dynamic batching is `),xe=r(fe,"STRONG",{});var Ws=i(xe);ls=p(Ws,"essential"),Ws.forEach(t),ps=p(fe," to provide a decent experience for everyone."),fe.forEach(t),this.h()},h(){c(f,"name","hf:doc:metadata"),c(f,"content",JSON.stringify(ta)),c(T,"id","using-pipelines-for-a-webserver"),c(T,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(T,"href","#using-pipelines-for-a-webserver"),c(d,"class","relative group"),c(Z,"href","pipeline_tutorial#using-pipelines-on-a-dataset"),c(B,"id","few-things-you-might-want-to-consider"),c(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(B,"href","#few-things-you-might-want-to-consider"),c(q,"class","relative group"),c(R,"id","error-checking"),c(R,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(R,"href","#error-checking"),c(_,"class","relative group"),c(I,"id","circuit-breaking"),c(I,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(I,"href","#circuit-breaking"),c(j,"class","relative group"),c(M,"id","blocking-the-main-thread"),c(M,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(M,"href","#blocking-the-main-thread"),c(E,"class","relative group"),c(D,"id","dynamic-batching"),c(D,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(D,"href","#dynamic-batching"),c(P,"class","relative group"),c(ce,"href","./main_classes/pipelines#pipeline-batching")},m(e,a){s(document.head,f),o(e,m,a),o(e,d,a),s(d,T),s(T,de),g(U,de,null),s(d,bt),s(d,ye),s(ye,kt),o(e,Ce,a),g(A,e,a),o(e,Oe,a),o(e,S,a),s(S,$t),s(S,Z),s(Z,qt),s(S,_t),o(e,Be,a),o(e,ee,a),s(ee,jt),o(e,Re,a),o(e,x,a),s(x,Et),s(x,we),s(we,Pt),s(x,Tt),o(e,ze,a),o(e,N,a),s(N,At),s(N,ge),s(ge,St),s(N,xt),o(e,Ie,a),g(G,e,a),o(e,Me,a),o(e,te,a),s(te,Nt),o(e,De,a),g(H,e,a),o(e,Ue,a),o(e,se,a),s(se,Ct),o(e,Ge,a),g(L,e,a),o(e,He,a),o(e,ae,a),s(ae,Ot),o(e,Le,a),o(e,C,a),s(C,Bt),s(C,ve),s(ve,Rt),s(C,zt),o(e,We,a),g(W,e,a),o(e,Fe,a),g(O,e,a),o(e,Je,a),o(e,oe,a),s(oe,It),o(e,Qe,a),o(e,ne,a),s(ne,Mt),o(e,Ke,a),o(e,re,a),s(re,Dt),o(e,Xe,a),o(e,q,a),s(q,B),s(B,be),g(F,be,null),s(q,Ut),s(q,ke),s(ke,Gt),o(e,Ve,a),o(e,_,a),s(_,R),s(R,$e),g(J,$e,null),s(_,Ht),s(_,qe),s(qe,Lt),o(e,Ye,a),o(e,ie,a),s(ie,Wt),o(e,Ze,a),o(e,z,a),s(z,Ft),s(z,_e),s(_e,Jt),s(z,Qt),o(e,et,a),o(e,j,a),s(j,I),s(I,je),g(Q,je,null),s(j,Kt),s(j,Ee),s(Ee,Xt),o(e,tt,a),o(e,le,a),s(le,Vt),o(e,st,a),o(e,pe,a),s(pe,Yt),o(e,at,a),o(e,E,a),s(E,M),s(M,Pe),g(K,Pe,null),s(E,Zt),s(E,Te),s(Te,es),o(e,ot,a),o(e,he,a),s(he,ts),o(e,nt,a),o(e,ue,a),s(ue,ss),o(e,rt,a),o(e,P,a),s(P,D),s(D,Ae),g(X,Ae,null),s(P,as),s(P,Se),s(Se,os),o(e,it,a),o(e,$,a),s($,ns),s($,ce),s(ce,rs),s($,is),s($,xe),s(xe,ls),s($,ps),lt=!0},p(e,[a]){const V={};a&2&&(V.$$scope={dirty:a,ctx:e}),A.$set(V);const Ne={};a&2&&(Ne.$$scope={dirty:a,ctx:e}),O.$set(Ne)},i(e){lt||(v(U.$$.fragment,e),v(A.$$.fragment,e),v(G.$$.fragment,e),v(H.$$.fragment,e),v(L.$$.fragment,e),v(W.$$.fragment,e),v(O.$$.fragment,e),v(F.$$.fragment,e),v(J.$$.fragment,e),v(Q.$$.fragment,e),v(K.$$.fragment,e),v(X.$$.fragment,e),lt=!0)},o(e){b(U.$$.fragment,e),b(A.$$.fragment,e),b(G.$$.fragment,e),b(H.$$.fragment,e),b(L.$$.fragment,e),b(W.$$.fragment,e),b(O.$$.fragment,e),b(F.$$.fragment,e),b(J.$$.fragment,e),b(Q.$$.fragment,e),b(K.$$.fragment,e),b(X.$$.fragment,e),lt=!1},d(e){t(f),e&&t(m),e&&t(d),k(U),e&&t(Ce),k(A,e),e&&t(Oe),e&&t(S),e&&t(Be),e&&t(ee),e&&t(Re),e&&t(x),e&&t(ze),e&&t(N),e&&t(Ie),k(G,e),e&&t(Me),e&&t(te),e&&t(De),k(H,e),e&&t(Ue),e&&t(se),e&&t(Ge),k(L,e),e&&t(He),e&&t(ae),e&&t(Le),e&&t(C),e&&t(We),k(W,e),e&&t(Fe),k(O,e),e&&t(Je),e&&t(oe),e&&t(Qe),e&&t(ne),e&&t(Ke),e&&t(re),e&&t(Xe),e&&t(q),k(F),e&&t(Ve),e&&t(_),k(J),e&&t(Ye),e&&t(ie),e&&t(Ze),e&&t(z),e&&t(et),e&&t(j),k(Q),e&&t(tt),e&&t(le),e&&t(st),e&&t(pe),e&&t(at),e&&t(E),k(K),e&&t(ot),e&&t(he),e&&t(nt),e&&t(ue),e&&t(rt),e&&t(P),k(X),e&&t(it),e&&t($)}}}const ta={local:"using-pipelines-for-a-webserver",sections:[{local:"few-things-you-might-want-to-consider",sections:[{local:"error-checking",title:"Error checking"},{local:"circuit-breaking",title:"Circuit breaking"},{local:"blocking-the-main-thread",title:"Blocking the main thread"},{local:"dynamic-batching",title:"Dynamic batching"}],title:"Few things you might want to consider"}],title:"Using pipelines for a webserver"};function sa(Y){return Vs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ia extends Js{constructor(f){super();Qs(this,f,sa,ea,Ks,{})}}export{ia as default,ta as metadata};
