From 70fa4aabeb92d2880b00cf013587d9f0a041579a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 12 Mar 2018 09:04:52 -0400 Subject: [PATCH] remove background task, as it's problematic #1589 --- pipenv/cli.py | 4 +-- pipenv/core.py | 20 ------------- pipenv/vendor/background.py | 60 ------------------------------------- 3 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 pipenv/vendor/background.py diff --git a/pipenv/cli.py b/pipenv/cli.py index 32df7c4a..c43c6fee 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -62,9 +62,7 @@ def cli( from . import core if not update: - if core.need_update_check(): - # Spun off in background thread, not unlike magic. - core.check_for_updates() + pass else: # Update pip to latest version. core.ensure_latest_pip() diff --git a/pipenv/core.py b/pipenv/core.py index 516386c8..2ea4fddf 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -13,7 +13,6 @@ import tempfile from glob import glob import json as simplejson -import background import click import click_completion import crayons @@ -140,25 +139,6 @@ def add_to_path(p): os.environ['PATH'] = '{0}{1}{2}'.format(p, os.pathsep, os.environ['PATH']) -@background.task -def check_for_updates(): - """Background thread -- beautiful, isn't it?""" - try: - touch_update_stamp() - r = requests.get('https://pypi.python.org/pypi/pipenv/json', timeout=0.5) - latest = max(map(semver.parse_version_info, r.json()['releases'].keys())) - current = semver.parse_version_info(__version__) - - if latest > current: - click.echo('{0}: {1} is now available. You get bonus points for upgrading ($ {})!'.format( - crayons.green('Courtesy Notice'), - crayons.yellow('Pipenv {v.major}.{v.minor}.{v.patch}'.format(v=latest)), - crayons.red('pipenv --update') - ), err=True) - except Exception: - pass - - def ensure_latest_self(user=False): """Updates Pipenv to latest version, cleverly.""" touch_update_stamp() diff --git a/pipenv/vendor/background.py b/pipenv/vendor/background.py deleted file mode 100644 index 5b513f60..00000000 --- a/pipenv/vendor/background.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- - -import sys -import multiprocessing - -try: - if sys.version_info.major < 3: - import concurrent27.futures as concurrent - else: - import concurrent.futures as concurrent -except ImportError: - pass - - - -def default_n(): - return multiprocessing.cpu_count() - -n = default_n() - -if 'concurrent' in globals(): - pool = concurrent.ThreadPoolExecutor(max_workers=n) -else: - pool = None -callbacks = [] -results = [] - - -def run(f, *args, **kwargs): - - if pool: - pool._max_workers = n - pool._adjust_thread_count() - - f = pool.submit(f, *args, **kwargs) - results.append(f) - - return f - - -def task(f, *args, **kwargs): - def do_task(): - result = run(f, *args, **kwargs) - results.append(result) - - for cb in callbacks: - result.add_done_callback(cb) - - return result - return do_task - - -def callback(f): - callbacks.append(f) - - def register_callback(): - f() - - return register_callback \ No newline at end of file