-
Notifications
You must be signed in to change notification settings - Fork 140
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
Improved handling of spawned functions in socket server #1524
Comments
From now back on this after Samba cycle |
Hi @schakrava and @phillxnet , First of all, school time!: Roadmap: perform tests with one emitter, find best solutions, extend it to other emitters/classes. First test class ServicesNamespace(socketio.Namespace):
start = False
threads = [] #1
def on_connect(self, sid, environ):
self.emit('connected', {
'key': 'services:connected', 'data': 'connected'
})
self.start = True
print('Connection opened - sid: %s' % sid) #Debug to supervisord
sys.stdout.flush()
self.threads.append(gevent.spawn(self.send_service_statuses, sid)) #2
def on_disconnect(self, sid):
print('Greenlets : %s' % self.threads) #Debug to supervisord
print('Connection closed - sid: %s' % sid)
sys.stdout.flush()
gevent.killall(self.threads) #3
self.threads = [] #3
self.start = False
def send_service_statuses(self, sid):
while self.start:
print('Emitting to sid: %s' % sid)
sys.stdout.flush() To grant an easier debugging had some Emitting to sid: 7b384aa4ef4b4347a3f2055dae808947
Greenlets : [<Greenlet at 0x2bc5050: <bound method ServicesNamespace.send_service_statuses of <smart_manager.data_collector.ServicesNamespace object at 0x28e0f10>>('7b384aa4ef4b4347a3f2055dae808947')>]
Connection closed - sid: 4adcc98a7d6f4daa92116a3fcb26b6ca
Greenlets : [<Greenlet at 0x2bc5050: <bound method ServicesNamespace.send_service_statuses of <smart_manager.data_collector.ServicesNamespace object at 0x28e0f10>>('7b384aa4ef4b4347a3f2055dae808947')>]
Connection closed - sid: 7b384aa4ef4b4347a3f2055dae808947
Greenlets : []
Connection closed - sid: 4adcc98a7d6f4daa92116a3fcb26b6ca
Connection opened - sid: f3a2c084924b4314ae246c4769104c57 Reading code:
Does this solve zomby threads? Yep! Probably going to PR before tomorrow |
Signed-off-by: Mirko Arena <[email protected]>
Hi all, M |
Signed-off-by: Mirko Arena <[email protected]>
Hi @schakrava ,
this is a memo/reference for upcoming (next days) PR related to #1522 (comment) and #1510
Testing together on new python-socketio for #1510 is good and now I'll check gevent.spawn + that glitch
Important: on every F5 (page refresh) we get for each
gevent.spawn
2 active threads instead of 1 as expected, that should be quite safe (not a real cpu eater), but better to avoid it and close this before 3.8.16 releaseMirko
The text was updated successfully, but these errors were encountered: