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

SocketIO signal issue #387

Closed
w8eight opened this issue Nov 27, 2019 · 3 comments
Closed

SocketIO signal issue #387

w8eight opened this issue Nov 27, 2019 · 3 comments

Comments

@w8eight
Copy link

w8eight commented Nov 27, 2019

Hi,

I am trying to run some application using python-socketio as Windows Service and while executing this line into cmd: 'python myapplication.py start' I am getting following error.

File "C:\Users\w23209\Documents\Subversion\Webservice\Digital Factory Web Service\src\frontend\server.py", line 14, in <module> from socketio.server import Server File "C:\Users\w23209\Documents\Subversion\Webservice\venv\Lib\site-packages\socketio\__init__.py", line 3, in <module> from .client import Client File "C:\Users\w23209\Documents\Subversion\Webservice\venv\Lib\site-packages\socketio\client.py", line 6, in <module> import engineio File "C:\Users\w23209\Documents\Subversion\Webservice\venv\Lib\site-packages\engineio\__init__.py", line 3, in <module> from .client import Client File "C:\Users\w23209\Documents\Subversion\Webservice\venv\Lib\site-packages\engineio\client.py", line 49, in <module> original_signal_handler = signal.signal(signal.SIGINT, signal_handler) File "C:\Program Files\Python37\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 %2: %3

Any idea what can cause such error?

Python 3.7.4, running from virtualenv

@miguelgrinberg
Copy link
Owner

What webserver are you using? Can you show me the code that runs as a response of the start argument passed into your script?

@w8eight
Copy link
Author

w8eight commented Nov 28, 2019

What webserver are you using? Can you show me the code that runs as a response of the start argument passed into your script?

I am using pywin32 hadnle 'start':
win32serviceutil.HandleCommandLine(MyService)
MyService is class inheriting from 'win32serviceutil.ServiceFramework'

Inside Myservice class SvcDoRun function starts actual server.

And this is server class

import bottle
from socketio.server import Server

class GeventSocketIOServer(bottle.ServerAdapter):
    def run(self, handler):
        address = (self.host, self.port)
        self.srv = Server(address, handler, **self.options)
        try:
            log.debug('serve forever')
            self.srv.serve_forever()
            log.debug('stopped serve forever')
        except KeyboardInterrupt:
            self.srv.close()
            raise

Resolving issue is no longer needed for me because I used pywsgi gevent server instead.

@miguelgrinberg
Copy link
Owner

Thanks. I've written miguelgrinberg/python-engineio#147 to keep track of this issue, so I'll close this one here.

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

2 participants