Staging
v0.5.1
https://github.com/python/cpython
Revision 5013a5ebc9978a58435036fa3860c465882c21da authored by Victor Stinner on 12 September 2017, 21:18:23 UTC, committed by GitHub on 12 September 2017, 21:18:23 UTC
* bpo-31250, test_asyncio: fix dangling threads (#3252)

* Explicitly call shutdown(wait=True) on executors to wait until all
  threads complete to prevent side effects between tests.
* Fix test_loop_self_reading_exception(): don't mock loop.close().
  Previously, the original close() method was called rather than the
  mock, because how set_event_loop() registered loop.close().

(cherry picked from commit 16432beadb8eba079c9786cc0c0eaacfd9fd2f7b)

* bpo-31250, test_asyncio: fix EventLoopTestsMixin.tearDown() (#3264)

Call doCleanups() to close the loop after calling
executor.shutdown(wait=True): see TestCase.set_event_loop() of
asyncio.test_utils.

Replace also gc.collect() with support.gc_collect().

(cherry picked from commit e8a533fbc734af6eeb389202ba6c6e9c2548027f)
1 parent 4d7807a
Raw File
Tip revision: 5013a5ebc9978a58435036fa3860c465882c21da authored by Victor Stinner on 12 September 2017, 21:18:23 UTC
[3.6] bpo-31250: test_asyncio: fix dangling threads (#3517)
Tip revision: 5013a5e
get_external.py
#!/usr/bin/env python3

import argparse
import os
import pathlib
import zipfile
from urllib.request import urlretrieve


def fetch_zip(commit_hash, zip_dir, *, org='python', binary=False, verbose):
    repo = f'cpython-{"bin" if binary else "source"}-deps'
    url = f'https://github.com/{org}/{repo}/archive/{commit_hash}.zip'
    reporthook = None
    if verbose:
        reporthook = print
    zip_dir.mkdir(parents=True, exist_ok=True)
    filename, headers = urlretrieve(
        url,
        zip_dir / f'{commit_hash}.zip',
        reporthook=reporthook,
    )
    return filename


def extract_zip(externals_dir, zip_path):
    with zipfile.ZipFile(os.fspath(zip_path)) as zf:
        zf.extractall(os.fspath(externals_dir))
        return externals_dir / zf.namelist()[0].split('/')[0]


def parse_args():
    p = argparse.ArgumentParser()
    p.add_argument('-v', '--verbose', action='store_true')
    p.add_argument('-b', '--binary', action='store_true',
                   help='Is the dependency in the binary repo?')
    p.add_argument('-O', '--organization',
                   help='Organization owning the deps repos', default='python')
    p.add_argument('-e', '--externals-dir', type=pathlib.Path,
                   help='Directory in which to store dependencies',
                   default=pathlib.Path(__file__).parent.parent / 'externals')
    p.add_argument('tag',
                   help='tag of the dependency')
    return p.parse_args()


def main():
    args = parse_args()
    zip_path = fetch_zip(
        args.tag,
        args.externals_dir / 'zips',
        org=args.organization,
        binary=args.binary,
        verbose=args.verbose,
    )
    final_name = args.externals_dir / args.tag
    extract_zip(args.externals_dir, zip_path).replace(final_name)


if __name__ == '__main__':
    main()
back to top