refactor nothing
This commit is contained in:
parent
1e70d49531
commit
f6cd0ef986
@ -4,7 +4,7 @@ from collections import deque
|
||||
from funcy import repeatedly, identity
|
||||
|
||||
from pyinfra.exceptions import NoBufferCapacity
|
||||
from pyinfra.server.dispatcher.dispatcher import Nothing
|
||||
from pyinfra.server.nothing import Nothing
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ from itertools import takewhile
|
||||
|
||||
from funcy import repeatedly
|
||||
|
||||
from pyinfra.server.dispatcher.dispatcher import is_not_nothing, Nothing
|
||||
from pyinfra.server.nothing import is_not_nothing, Nothing
|
||||
|
||||
|
||||
def stream_queue(queue):
|
||||
|
||||
@ -4,7 +4,7 @@ from typing import Iterable
|
||||
from funcy import first, repeatedly, mapcat
|
||||
|
||||
from pyinfra.server.buffering.bufferize import bufferize
|
||||
from pyinfra.server.dispatcher.dispatcher import Nothing, is_not_nothing
|
||||
from pyinfra.server.nothing import Nothing, is_not_nothing
|
||||
|
||||
|
||||
class FlatStreamBuffer:
|
||||
|
||||
@ -3,13 +3,7 @@ from typing import Iterable
|
||||
|
||||
from more_itertools import peekable
|
||||
|
||||
|
||||
class Nothing:
|
||||
pass
|
||||
|
||||
|
||||
def is_not_nothing(x):
|
||||
return x is not Nothing
|
||||
from pyinfra.server.nothing import Nothing
|
||||
|
||||
|
||||
def has_next(peekable_iter):
|
||||
|
||||
6
pyinfra/server/nothing.py
Normal file
6
pyinfra/server/nothing.py
Normal file
@ -0,0 +1,6 @@
|
||||
class Nothing:
|
||||
pass
|
||||
|
||||
|
||||
def is_not_nothing(x):
|
||||
return x is not Nothing
|
||||
@ -1,39 +0,0 @@
|
||||
# from typing import Iterable
|
||||
#
|
||||
# from funcy import rcompose
|
||||
#
|
||||
# from pyinfra.server.dispatcher.dispatchers.rest import RestDispatcher
|
||||
# from pyinfra.server.interpreter.interpreters.identity import IdentityInterpreter
|
||||
# from pyinfra.server.interpreter.interpreters.rest_callback import RestPickupStreamer
|
||||
# from pyinfra.server.packer.packers.rest import RestPacker
|
||||
# from pyinfra.server.client_pipeline import ClientPipeline
|
||||
# from pyinfra.server.receiver.receivers.rest import RestReceiver
|
||||
#
|
||||
#
|
||||
# def process_eagerly(endpoint, data: Iterable[bytes], metadata: Iterable[dict]):
|
||||
# """Posts `data` to `url` and aggregates responses for each element of `data`."""
|
||||
# pipeline = get_eager_pipeline(endpoint)
|
||||
# yield from pipeline(data, metadata)
|
||||
#
|
||||
#
|
||||
# def process_lazily(endpoint, data: Iterable[bytes], metadata: Iterable[dict]):
|
||||
# """Posts `data` to `url` and aggregates responses for each element of `data` by querying a pickup endpoint.
|
||||
#
|
||||
# Requires:
|
||||
# - responses must provide return pickup_endpoint as JSON payload
|
||||
# - responses must have status code 206 for more responses coming and 204 for the last response already sent
|
||||
# """
|
||||
# pipeline = get_lazy_pipeline(endpoint)
|
||||
# yield from pipeline(data, metadata)
|
||||
#
|
||||
#
|
||||
# def get_eager_pipeline(endpoint):
|
||||
# return ClientPipeline(*pipeline_head(endpoint), IdentityInterpreter())
|
||||
#
|
||||
#
|
||||
# def get_lazy_pipeline(endpoint):
|
||||
# return ClientPipeline(*pipeline_head(endpoint), rcompose(RestPickupStreamer(), RestReceiver()))
|
||||
#
|
||||
#
|
||||
# def pipeline_head(url):
|
||||
# return RestPacker(), RestDispatcher(url), RestReceiver()
|
||||
@ -3,10 +3,10 @@ import logging
|
||||
from flask import jsonify
|
||||
from funcy import drop
|
||||
|
||||
from pyinfra.server.dispatcher.dispatcher import Nothing
|
||||
from pyinfra.server.nothing import Nothing
|
||||
from pyinfra.server.stream.queued_stream_function import QueuedStreamFunction
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LazyRestProcessor:
|
||||
@ -27,10 +27,12 @@ class LazyRestProcessor:
|
||||
result = Nothing
|
||||
|
||||
if result is Nothing:
|
||||
logger.info("Analysis completed successfully.")
|
||||
resp = jsonify("No more items left")
|
||||
resp.status_code = 204
|
||||
|
||||
else:
|
||||
logger.debug("Partial analysis completed.")
|
||||
resp = jsonify(result)
|
||||
resp.status_code = 206
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ from funcy import omit, filter, first, lpluck, identity
|
||||
from more_itertools import peekable
|
||||
|
||||
from pyinfra.file_descriptor_manager import FileDescriptorManager
|
||||
from pyinfra.server.dispatcher.dispatcher import Nothing, is_not_nothing
|
||||
from pyinfra.server.nothing import Nothing, is_not_nothing
|
||||
from pyinfra.utils.encoding import pack_analysis_payload
|
||||
from pyinfra.visitor.strategies.response.response import ResponseStrategy
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user