Use timemout for project auto close to avoid issue when client / connect

This commit is contained in:
Julien Duponchelle 2016-08-19 17:40:07 +02:00
parent 39db35c3ff
commit 8f7be87b1e
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -213,7 +213,11 @@ class ProjectHandler:
except asyncio.futures.CancelledError as e:
break
if project.auto_close and not controller.notification.project_has_listeners(project):
if project.auto_close:
# To avoid trouble with client connecting disconnecting we sleep few seconds before checking
# if someone else is not connected
yield from asyncio.sleep(5)
if not controller.notification.project_has_listeners(project):
yield from project.close()
@Route.get(
@ -247,7 +251,11 @@ class ProjectHandler:
break
ws.send_str(notification)
if project.auto_close and not controller.notification.project_has_listeners(project):
if project.auto_close:
# To avoid trouble with client connecting disconnecting we sleep few seconds before checking
# if someone else is not connected
yield from asyncio.sleep(5)
if not controller.notification.project_has_listeners(project):
yield from project.close()
return ws