OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2013 Google Inc. All Rights Reserved. | 2 # Copyright 2013 Google Inc. All Rights Reserved. |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 (bool indicator if multiprocessing should be prohibited, OS name) | 244 (bool indicator if multiprocessing should be prohibited, OS name) |
245 """ | 245 """ |
246 if system_util.IS_WINDOWS: | 246 if system_util.IS_WINDOWS: |
247 return (True, 'Windows') | 247 return (True, 'Windows') |
248 try: | 248 try: |
249 with open('/etc/os-release', 'r') as f: | 249 with open('/etc/os-release', 'r') as f: |
250 os_name = f.read().split('\n')[0].split('=')[1].strip('"') | 250 os_name = f.read().split('\n')[0].split('=')[1].strip('"') |
251 return ('alpine linux' in os_name.lower(), os_name) | 251 return ('alpine linux' in os_name.lower(), os_name) |
252 except IOError as e: | 252 except IOError as e: |
253 if e.errno == errno.ENOENT: | 253 if e.errno == errno.ENOENT: |
254 raise IOError('Unable to open /etc/os-release to determine OS release') | 254 logger.debug('Unable to open /etc/os-release to determine whether OS ' |
| 255 'supports multiprocessing: errno=%d, message=%s' |
| 256 % (e.errno, e.message)) |
| 257 return (False, 'Unknown') |
255 else: | 258 else: |
256 raise | 259 raise |
257 | 260 |
258 | 261 |
259 def CheckMultiprocessingAvailableAndInit(logger=None): | 262 def CheckMultiprocessingAvailableAndInit(logger=None): |
260 """Checks if multiprocessing is available, and if so performs initialization. | 263 """Checks if multiprocessing is available, and if so performs initialization. |
261 | 264 |
262 There are some environments in which there is no way to use multiprocessing | 265 There are some environments in which there is no way to use multiprocessing |
263 logic that's built into Python (e.g., if /dev/shm is not available, then | 266 logic that's built into Python (e.g., if /dev/shm is not available, then |
264 we can't create semaphores). This simply tries out a few things that will be | 267 we can't create semaphores). This simply tries out a few things that will be |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 timeout: (optional) amount of time to wait before repeating put request. | 417 timeout: (optional) amount of time to wait before repeating put request. |
415 """ | 418 """ |
416 put_success = False | 419 put_success = False |
417 while not put_success: | 420 while not put_success: |
418 try: | 421 try: |
419 queue.put(msg, timeout=timeout) | 422 queue.put(msg, timeout=timeout) |
420 put_success = True | 423 put_success = True |
421 except Queue.Full: | 424 except Queue.Full: |
422 pass | 425 pass |
423 # pylint: enable=invalid-name | 426 # pylint: enable=invalid-name |
OLD | NEW |