remove background task, as it's problematic #1589

This commit is contained in:
2018-03-12 09:04:52 -04:00
parent 9ac3d05955
commit 70fa4aabeb
3 changed files with 1 additions and 83 deletions
+1 -3
View File
@@ -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()
-20
View File
@@ -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()
-60
View File
@@ -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