dgl icon indicating copy to clipboard operation
dgl copied to clipboard

'ValueError: signal only works in main thread' when using with streamlit

Open sergei-grechanik opened this issue 6 years ago • 2 comments

I tried to import dgl from within a streamlit app, and got an exception ValueError: signal only works in main thread. I guess streamlit runs scripts in a non-main thread, and dgl tries to override the signal handler here: https://github.com/dmlc/dgl/blob/346bc235565a617a0c76074c25019d6dd0003ece/python/dgl/network.py#L27

Overriding the signal handler during library import doesn't feel right. Since right now the handler doesn't seem to do anything useful anyway, I would suggest simply removing it.

To reproduce:

echo "import dgl" > dgl_signal_bug.py && streamlit run dgl_signal_bug.py 

cc @aksnzhy

sergei-grechanik avatar Jan 04 '20 21:01 sergei-grechanik

@sergei-grechanik Hi, I have fixed this issue by removing the signal handler https://github.com/dmlc/dgl/pull/1171.

Thanks so much!

aksnzhy avatar Jan 05 '20 06:01 aksnzhy

hi, I'm getting this error too. Would you let me know how you fixed it? Thanks!

asor12 avatar Feb 27 '21 06:02 asor12