~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-22 22:35:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5683.
  • Revision ID: jelmer@samba.org-20110222223508-kewyszv98r64l7za
Use try/import rather than checking python version strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2243
2243
            termios.tcsetattr(fd, termios.TCSADRAIN, settings)
2244
2244
        return ch
2245
2245
 
2246
 
if sys.version_info >= (2, 6):
2247
 
    def _local_concurrency():
2248
 
        import multiprocessing
2249
 
        return multiprocessing.cpu_count()
2250
 
elif sys.platform == 'linux2':
 
2246
if sys.platform == 'linux2':
2251
2247
    def _local_concurrency():
2252
2248
        try:
2253
2249
            return os.sysconf('SC_NPROCESSORS_ONLN')
2291
2287
    concurrency = os.environ.get('BZR_CONCURRENCY', None)
2292
2288
    if concurrency is None:
2293
2289
        try:
2294
 
            concurrency = _local_concurrency()
2295
 
        except (OSError, IOError):
2296
 
            pass
 
2290
            import multiprocessing
 
2291
        except ImportError:
 
2292
            # multiprocessing is only available on Python >= 2.6
 
2293
            try:
 
2294
                concurrency = _local_concurrency()
 
2295
            except (OSError, IOError):
 
2296
                pass
 
2297
        else:
 
2298
            concurrency = multiprocessing.cpu_count()
2297
2299
    try:
2298
2300
        concurrency = int(concurrency)
2299
2301
    except (TypeError, ValueError):