Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option in get_server function to not use signals #342

Closed
xavArtley opened this issue Mar 29, 2019 · 0 comments
Closed

Add an option in get_server function to not use signals #342

xavArtley opened this issue Mar 29, 2019 · 0 comments

Comments

@xavArtley
Copy link
Collaborator

I have an application where I have not access to the main python thread
I'd like to be able to launch a server with the panel utility function get_server
I simulate what should be achieved with a MRE:
ezgif com-video-to-gif (1)
Associated code

import panel as pn
from panel.io.server import get_server, StoppableThread
slider = pn.widgets.FloatSlider()
class PanelServerThread(StoppableThread):
    
    def run(self):
        import asyncio
        asyncio.set_event_loop(asyncio.new_event_loop())
        self.server = get_server(slider, port=5006)
        self.server.start()
        self.server.io_loop.start()

th = PanelServerThread()
th.start()
slider.value = 0.5

However to make this code works I had to comment the line 95 in panel.io.server.py
If not I get thiss error:

Exception in thread Thread-18:
Traceback (most recent call last):
  File "D:\CIVA_RP\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "<ipython-input-3-97ff3fa09bcb>", line 7, in run
    self.server = get_server(slider, port=5006)
  File "D:\CIVA_RP\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\site-packages\panel\io\server.py", line 95, in get_server
    signal.signal(signal.SIGINT, sig_exit)
  File "D:\CIVA_RP\civa-rep\ProjetCIVA\ceaComponents\dev\python\lib\signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

So I'd like to request may be an argument to make it optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant