mirror of
https://github.com/httpie/cli.git
synced 2024-11-27 02:03:31 +01:00
Apply review feedback.
This commit is contained in:
parent
6e75c5244d
commit
309037fca9
6
Makefile
6
Makefile
@ -154,10 +154,10 @@ doc-check:
|
||||
|
||||
build:
|
||||
rm -rf build/ dist/
|
||||
mv httpie/internal/_build_channel.py httpie/internal/_build_channel.py.original
|
||||
echo 'BUILD_CHANNEL = "pip"' > httpie/internal/_build_channel.py
|
||||
mv httpie/internal/__build_channel__.py httpie/internal/__build_channel__.py.original
|
||||
echo 'BUILD_CHANNEL = "pip"' > httpie/internal/__build_channel__.py
|
||||
$(VENV_PYTHON) -m build --sdist --wheel --outdir dist/
|
||||
mv httpie/internal/_build_channel.py.original httpie/internal/_build_channel.py
|
||||
mv httpie/internal/__build_channel__.py.original httpie/internal/__build_channel__.py
|
||||
|
||||
|
||||
publish: test-all publish-no-test
|
||||
|
@ -27,7 +27,7 @@ RUN python -m pip install /app
|
||||
RUN python -m pip install pyinstaller wheel
|
||||
RUN python -m pip install --force-reinstall --upgrade pip
|
||||
|
||||
RUN echo 'BUILD_CHANNEL="pypi"' > /app/httpie/internal/_build_channel.py
|
||||
RUN echo 'BUILD_CHANNEL="pypi"' > /app/httpie/internal/__build_channel__.py
|
||||
RUN python build.py
|
||||
|
||||
ENTRYPOINT ["mv", "/app/extras/packaging/linux/dist/", "/artifacts"]
|
||||
|
@ -6,7 +6,7 @@ from httpie.context import Environment
|
||||
from httpie.internal.update_warnings import _fetch_updates
|
||||
from httpie.status import ExitStatus
|
||||
|
||||
STATUS_FILE = '.status'
|
||||
STATUS_FILE = '.httpie-test-daemon-status'
|
||||
|
||||
|
||||
def _check_status(env):
|
||||
|
@ -1,3 +1,10 @@
|
||||
"""
|
||||
This module provides an interface to spawn a detached task to be
|
||||
runned with httpie.internal.daemon_runner on a separate process. It is
|
||||
based on DVC's daemon system.
|
||||
https://github.com/iterative/dvc/blob/main/dvc/daemon.py
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import platform
|
||||
@ -6,12 +13,8 @@ import httpie.__main__
|
||||
from contextlib import suppress
|
||||
from subprocess import Popen
|
||||
from typing import Dict, List
|
||||
from httpie.compat import is_frozen
|
||||
from httpie.compat import is_frozen, is_windows
|
||||
|
||||
# This module provides an interface to spawn a detached task to be
|
||||
# runned with httpie.internal.daemon_runner on a separate process. It is
|
||||
# based on DVC's daemon system.
|
||||
# https://github.com/iterative/dvc/blob/main/dvc/daemon.py
|
||||
|
||||
ProcessContext = Dict[str, str]
|
||||
|
||||
@ -50,13 +53,15 @@ def _spawn_windows(cmd: List[str], process_context: ProcessContext) -> None:
|
||||
|
||||
|
||||
def _spawn_posix(args: List[str], process_context: ProcessContext) -> None:
|
||||
from httpie.core import main
|
||||
"""
|
||||
Perform a double fork procedure* to detach from the parent
|
||||
process so that we don't block the user even if their original
|
||||
command's execution is done but the release fetcher is not.
|
||||
|
||||
# Perform a double fork procedure* to detach from the parent
|
||||
# process so that we don't block the user even if their original
|
||||
# command's execution is done but the release fetcher is not.
|
||||
#
|
||||
# [1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html#tag_11_01_03
|
||||
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html#tag_11_01_03
|
||||
"""
|
||||
|
||||
from httpie.core import main
|
||||
|
||||
try:
|
||||
pid = os.fork()
|
||||
@ -94,6 +99,16 @@ def _spawn_posix(args: List[str], process_context: ProcessContext) -> None:
|
||||
os._exit(0)
|
||||
|
||||
|
||||
def _spawn(args: List[str], process_context: ProcessContext) -> None:
|
||||
"""
|
||||
Spawn a new process to run the given command.
|
||||
"""
|
||||
if is_windows:
|
||||
_spawn_windows(args, process_context)
|
||||
else:
|
||||
_spawn_posix(args, process_context)
|
||||
|
||||
|
||||
def spawn_daemon(task: str) -> None:
|
||||
args = [task, '--daemon']
|
||||
process_context = os.environ.copy()
|
||||
@ -103,9 +118,4 @@ def spawn_daemon(task: str) -> None:
|
||||
os.path.dirname(os.path.dirname(file_path))
|
||||
)
|
||||
|
||||
if os.name == 'nt':
|
||||
# Windows lacks os.fork(), so we need to
|
||||
# handle it separately.
|
||||
_spawn_windows(args, process_context)
|
||||
else:
|
||||
_spawn_posix(args, process_context)
|
||||
_spawn(args, process_context)
|
||||
|
@ -8,7 +8,7 @@ import requests
|
||||
|
||||
import httpie
|
||||
from httpie.context import Environment, LogLevel
|
||||
from httpie.internal._build_channel import BUILD_CHANNEL
|
||||
from httpie.internal.__build_channel__ import BUILD_CHANNEL
|
||||
from httpie.internal.daemons import spawn_daemon
|
||||
from httpie.utils import is_version_greater, open_with_lockfile
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user