[1.46][PATCH v2] hashserv: specify loop for asyncio in python < 3.6
[YOCTO #14697]
Detect python version 3.5 restoring loop argument where it is still required. In 3.6 auto loop detection is available.
Bitbake 1.46 is used in dunfell which lists a minimum python version of 3.5. Omitting this argument leads to a regression and hang during "Initialising tasks" at 44%.
--- lib/hashserv/server.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
lib/hashserv/server.py +17 -6
@@ -12,6 +12,7 @@ import math import os import signal import socket +import sys import time from . import chunkify, DEFAULT_MAX_CHUNK
@@ -419,9 +420,14 @@ class Server(object): self._cleanup_socket = None def start_tcp_server(self, host, port): - self.server = self.loop.run_until_complete( - asyncio.start_server(self.handle_client, host, port) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port, loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port) + ) for s in self.server.sockets: logger.info('Listening on %r' % (s.getsockname(),))
@@ -444,9 +450,14 @@ class Server(object): try: # Work around path length limits in AF_UNIX os.chdir(os.path.dirname(path)) - self.server = self.loop.run_until_complete( - asyncio.start_unix_server(self.handle_client, os.path.basename(path)) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path), loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path)) + ) finally: os.chdir(cwd)
Signature · 1 line
2.25.1
Hi Jate,
Just want to confirm that the only difference between V1 and V2 is the addition of the reference to the bug number?
Thanks,
Steve
Quoted 66 lines · Jate Sujjavanich
[YOCTO #14697]
Detect python version 3.5 restoring loop argument where it is still required. In 3.6 auto loop detection is available.
Bitbake 1.46 is used in dunfell which lists a minimum python version of 3.5. Omitting this argument leads to a regression and hang during "Initialising tasks" at 44%.
Signed-off-by Jate Sujjavanich <[email protected]>--- lib/hashserv/server.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)lib/hashserv/server.py +17
-7@@ -12,6 +12,7 @@ import math import os import signal import socket +import sys import time from . import chunkify, DEFAULT_MAX_CHUNK@@ -419,9 +420,14 @@ class Server(object): self._cleanup_socket = None def start_tcp_server(self, host, port): - self.server = self.loop.run_until_complete( - asyncio.start_server(self.handle_client, host, port) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port, loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port) + ) for s in self.server.sockets: logger.info('Listening on %r' % (s.getsockname(),))@@ -444,9 +450,14 @@ class Server(object): try: # Work around path length limits in AF_UNIX os.chdir(os.path.dirname(path)) - self.server = self.loop.run_until_complete( - asyncio.start_unix_server(self.handle_client, os.path.basename(path)) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path), loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path)) + ) finally: os.chdir(cwd) --2.25.1
- Changed the version check on the minor (< 7 to <6) after testing python 3.6 with bitbake.
- Changed the comment to reflect this
- Added Bugzilla tracker
Quoted 82 lines · Steve Sakoman
Hi Jate,
Just want to confirm that the only difference between V1 and V2 is the addition of the reference to the bug number?
Thanks,
Steve
Quoted 28 lines · Jate Sujjavanich
[YOCTO #14697]
Detect python version 3.5 restoring loop argument where it is still required. In 3.6 auto loop detection is available.
Bitbake 1.46 is used in dunfell which lists a minimum python version of 3.5. Omitting this argument leads to a regression and hang during "Initialising tasks" at 44%.
Signed-off-by Jate Sujjavanich <[email protected]>--- lib/hashserv/server.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)lib/hashserv/server.py +1
-0@@ -12,6 +12,7 @@ import math import os import signal import socket +import sys import time from . import chunkify, DEFAULT_MAX_CHUNKlib/hashserv/server.py class Server(object): · line 425
Quoted 9 lines
lib/hashserv/server.py +3
-3@@ -419,9 +420,14 @@ class Server(object): self._cleanup_socket = None def start_tcp_server(self, host, port): - self.server = self.loop.run_until_complete( - asyncio.start_server(self.handle_client, host, port) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port,loop=self.loop)
Quoted 9 lines
lib/hashserv/server.py +5
-0+ ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port) + ) for s in self.server.sockets: logger.info('Listening on %r' % (s.getsockname(),))lib/hashserv/server.py class Server(object): · line 448
Quoted 5 lines
lib/hashserv/server.py +0
-2@@ -444,9 +450,14 @@ class Server(object): try: # Work around path length limits in AF_UNIX os.chdir(os.path.dirname(path)) - self.server = self.loop.run_until_complete( - asyncio.start_unix_server(self.handle_client,
os.path.basename(path))lib/hashserv/server.py class Server(object):
Quoted 4 lines
lib/hashserv/server.py +3
-1- ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client,
os.path.basename(path), loop=self.loop)lib/hashserv/server.py class Server(object):
Quoted 4 lines
lib/hashserv/server.py +4
-0+ ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client,
os.path.basename(path))Quoted 7 lines
lib/hashserv/server.py +1
-1+ ) finally: os.chdir(cwd) --2.25.1
Quoted 4 lines · Jate Sujjavanich
- Changed the version check on the minor (< 7 to <6) after testing python 3.6 with bitbake.
- Changed the comment to reflect this
- Added Bugzilla tracker
Thanks!
Steve
Quoted 78 lines · Steve Sakoman
Quoted 77 lines
Hi Jate,
Just want to confirm that the only difference between V1 and V2 is the addition of the reference to the bug number?
Thanks,
Steve
Quoted 66 lines · Jate Sujjavanich
[YOCTO #14697]
Detect python version 3.5 restoring loop argument where it is still required. In 3.6 auto loop detection is available.
Bitbake 1.46 is used in dunfell which lists a minimum python version of 3.5. Omitting this argument leads to a regression and hang during "Initialising tasks" at 44%.
Signed-off-by Jate Sujjavanich <[email protected]>--- lib/hashserv/server.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)lib/hashserv/server.py +17
-7@@ -12,6 +12,7 @@ import math import os import signal import socket +import sys import time from . import chunkify, DEFAULT_MAX_CHUNK@@ -419,9 +420,14 @@ class Server(object): self._cleanup_socket = None def start_tcp_server(self, host, port): - self.server = self.loop.run_until_complete( - asyncio.start_server(self.handle_client, host, port) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port, loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_server(self.handle_client, host, port) + ) for s in self.server.sockets: logger.info('Listening on %r' % (s.getsockname(),))@@ -444,9 +450,14 @@ class Server(object): try: # Work around path length limits in AF_UNIX os.chdir(os.path.dirname(path)) - self.server = self.loop.run_until_complete( - asyncio.start_unix_server(self.handle_client, os.path.basename(path)) - ) + if sys.version_info[0] == 3 and sys.version_info[1] < 6: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path), loop=self.loop) + ) + else: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, os.path.basename(path)) + ) finally: os.chdir(cwd) --2.25.1