# Easy demo，but thread started， then loop in（self.started ）

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655%3E%5C
**Category:** 🔒 Gradio\
**Created:** [April 15, 2023, 5:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655 "2023-04-15T05:46:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cndavy](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cndavy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcndavy)%5C
**Post date:** [April 15, 2023, 5:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655%2F1 "2023-04-15T05:46:54Z")

</div>

import gradio as gr

def greet(name):  
return "Hello " + name + “!”

demo = gr.Interface(fn=greet, inputs=“text”, outputs=“text”)

if **name** == “ **main** ”:  
demo.launch()

class Server(uvicorn.Server):  
def install\_signal\_handlers(self):  
pass

```
def run_in_thread(self):
    self.thread = threading.Thread(target=self.run, daemon=True)
    self.thread.start()
    while not self.started:
        *time.sleep(1e-3)*

def close(self):
    self.should_exit = True
    self.thread.join()

```

tracing it find loop sleep ?

stack run\_in\_thread, networking.py:39  
start\_server, networking.py:163  
launch, blocks.py:1703  
, app.py:11

---

<div class="post-metadata">

**Author:** ![cndavy](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cndavy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcndavy)%5C
**Post date:** [April 15, 2023, 5:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655%2F2 "2023-04-15T05:54:41Z")

</div>

F:\Anaconda3\envs\chatglm\python.exe D:\chatglm-6b-int4\app.py  
Traceback (most recent call last):  
File “D:\chatglm-6b-int4\app.py”, line 11, in   
demo.launch()  
File “F:\Anaconda3\envs\chatglm\Lib\site-packages\gradio\blocks.py”, line 1703, in launch  
server\_name, server\_port, local\_url, app, server = networking.start\_server(  
^^^^^^^^^^^^^^^^^^^^^^^^  
File “F:\Anaconda3\envs\chatglm\Lib\site-packages\gradio\networking.py”, line 163, in start\_server  
server.run\_in\_thread()  
File “F:\Anaconda3\envs\chatglm\Lib\site-packages\gradio\networking.py”, line 39, in run\_in\_thread  
time.sleep(1e-3)  
KeyboardInterrupt

---

<div class="post-metadata">

**Author:** ![cndavy](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cndavy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcndavy)%5C
**Post date:** [April 15, 2023, 5:56am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655%2F3 "2023-04-15T05:56:14Z")

</div>

(chatglm) D:\chatglm-6b-int4\>pip list  
Package Version

* * *

aiofiles 23.1.0  
aiohttp 3.8.4  
aiosignal 1.3.1  
altair 4.2.2  
anyio 3.5.0  
appdirs 1.4.4  
argon2-cffi 21.3.0  
argon2-cffi-bindings 21.2.0  
asttokens 2.0.5  
async-timeout 4.0.2  
attrs 22.1.0  
Babel 2.11.0  
backcall 0.2.0  
beautifulsoup4 4.12.2  
bleach 4.1.0  
brotlipy 0.7.0  
certifi 2022.12.7  
cffi 1.15.1  
chardet 5.1.0  
charset-normalizer 2.0.4  
click 7.1.2  
colorama 0.4.6  
comm 0.1.2  
contourpy 1.0.7  
cpm-kernels 1.0.11  
cryptography 39.0.1  
cycler 0.11.0  
daal4py 2023.0.2  
debugpy 1.5.1  
decorator 5.1.1  
defusedxml 0.7.1  
docopt 0.6.2  
entrypoints 0.4  
executing 0.8.3  
fastapi 0.95.0  
fastjsonschema 2.16.2  
ffmpy 0.3.0  
filelock 3.11.0  
flit\_core 3.8.0  
fonttools 4.39.3  
frozenlist 1.3.3  
fsspec 2023.4.0  
gradio 3.27.0  
gradio\_client 0.1.3  
h11 0.14.0  
httpcore 0.17.0  
httpx 0.24.0  
huggingface-hub 0.13.4  
idna 3.4  
ipykernel 6.19.2  
ipython 8.12.0  
ipython-genutils 0.2.0  
ipywidgets 8.0.4  
jedi 0.18.1  
Jinja2 3.1.2  
joblib 1.1.1  
json5 0.9.6  
jsonschema 4.17.3  
jupyter 1.0.0  
jupyter\_client 8.1.0  
jupyter-console 6.6.3  
jupyter\_core 5.3.0  
jupyter-server 1.23.4  
jupyterlab 3.5.3  
jupyterlab-pygments 0.1.2  
jupyterlab\_server 2.22.0  
jupyterlab-widgets 3.0.5  
kiwisolver 1.4.4  
linkify-it-py 2.0.0  
lxml 4.9.2  
markdown-it-py 2.2.0  
MarkupSafe 2.1.1  
matplotlib 3.7.1  
matplotlib-inline 0.1.6  
mdit-py-plugins 0.3.3  
mdurl 0.1.2  
mistune 0.8.4  
mkl-fft 1.3.1  
mkl-random 1.2.2  
mkl-service 2.4.0  
mpmath 1.3.0  
multidict 6.0.4  
nbclassic 0.5.4  
nbclient 0.5.13  
nbconvert 6.5.4  
nbformat 5.7.0  
nest-asyncio 1.5.6  
networkx 3.1  
notebook 6.5.3  
notebook\_shim 0.2.2  
numpy 1.23.5  
orjson 3.8.10  
packaging 23.0  
pandas 2.0.0  
pandocfilters 1.5.0  
parso 0.8.3  
pickleshare 0.7.5  
Pillow 9.5.0  
pip 23.0.1  
pipreqs 0.4.12  
platformdirs 2.5.2  
ply 3.11  
pooch 1.4.0  
prometheus-client 0.14.1  
prompt-toolkit 3.0.36  
protobuf 4.22.1  
psutil 5.9.0  
pure-eval 0.2.2  
pycparser 2.21  
pydantic 1.10.7  
pydub 0.25.1  
Pygments 2.11.2  
pyOpenSSL 23.0.0  
pyparsing 3.0.9  
PyQt5 5.15.7  
PyQt5-sip 12.11.0  
pyrsistent 0.18.0  
PySocks 1.7.1  
python-dateutil 2.8.2  
python-multipart 0.0.6  
pytz 2022.7  
pywin32 305.1  
pywinpty 2.0.10  
PyYAML 6.0  
pyzmq 23.2.0  
qtconsole 5.4.2  
QtPy 2.2.0  
radio 0.1.3  
regex 2023.3.23  
requests 2.28.1  
scikit-learn 1.2.2  
scikit-learn-intelex 20230308.183507  
scipy 1.10.1  
semantic-version 2.10.0  
Send2Trash 1.8.0  
setuptools 65.6.3  
sip 6.6.2  
six 1.16.0  
sniffio 1.2.0  
soupsieve 2.4  
stack-data 0.2.0  
starlette 0.26.1  
sympy 1.11.1  
terminado 0.17.1  
threadpoolctl 2.2.0  
tinycss2 1.2.1  
tokenizers 0.13.3  
toml 0.10.2  
tomli 2.0.1  
toolz 0.12.0  
torch 2.0.0+cu118  
torchaudio 2.0.0+cu118  
torchvision 0.15.0+cu118  
tornado 6.2  
tqdm 4.65.0  
traitlets 5.7.1  
transformers 4.27.1  
typing\_extensions 4.4.0  
tzdata 2023.3  
uc-micro-py 1.0.1  
urllib3 1.26.15  
uvicorn 0.21.1  
wcwidth 0.2.5  
webencodings 0.5.1  
websocket-client 0.58.0  
websockets 11.0.1  
wheel 0.38.4  
widgetsnbextension 4.0.5  
win-inet-pton 1.1.0  
wincertstore 0.2  
yarg 0.1.9  
yarl 1.8.2

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffreddyaboulton)%5C
**Post date:** [April 24, 2023, 2:40pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Feasy-demo-but-thread-started-then-loop-in-self-started%2F36655%2F4 "2023-04-24T14:40:23Z")

</div>

Hi @cndavy ! Thanks for posting but it’s unclear what the issue/question about gradio is here. Can you please elaborate?
