예제 #1
0
def test_instacrash_raises_error():
    http = LambdaHttpClient('crashy', '', cwd=BASE_DIR, interpreter_args=[
        '-e', r'process.exit(5)'
    ])
    with pytest.raises(Exception, match="Subprocess failed with exit code 5"):
        http.get_url()
    assert http.is_running is False
예제 #2
0
def test_unparseable_port_raises_error():
    http = LambdaHttpClient(
        "bad_port",
        "",
        cwd=BASE_DIR,
        interpreter_args=["-e", r'console.log("SUP"); while (1) {}'])
    with pytest.raises(Exception,
                       match="Could not parse port from line: b'SUP"):
        http.get_url()
    assert http.is_running is False
예제 #3
0
def module_scoped_lambda_server():
    http = LambdaHttpClient(
        'test lambda http script',
        LAMBDA_SCRIPT,
        cwd=BASE_DIR,
        interpreter_args=['-r', './frontend/webpack/babel-register'],
        restart_on_script_change=True
    )
    yield http
    http.shutdown()
예제 #4
0
def test_hanging_without_stdout_raises_error():
    http = LambdaHttpClient("hang",
                            "",
                            cwd=BASE_DIR,
                            timeout_secs=0.001,
                            interpreter_args=["-e", r"while (1) {}"])
    with pytest.raises(Exception,
                       match="Subprocess produced no output within 0.001s"):
        http.get_url()
    assert http.is_running is False
예제 #5
0
파일: views.py 프로젝트: ma8642/tenants2
FORMS_COMMON_DATA = common_data.load_json("forms.json")

NS_PER_MS = 1e+6

LAMBDA_SCRIPT = BASE_DIR / 'lambda.js'

logger = logging.getLogger(__name__)

lambda_service: LambdaService

if settings.USE_LAMBDA_HTTP_SERVER:
    from project.util.lambda_http_client import LambdaHttpClient

    lambda_service = LambdaHttpClient('ReactHttp',
                                      LAMBDA_SCRIPT,
                                      script_args=['--serve-http'],
                                      cwd=BASE_DIR,
                                      restart_on_script_change=settings.DEBUG)
else:
    from project.util.lambda_pool import LambdaPool

    lambda_service = LambdaPool('React',
                                LAMBDA_SCRIPT,
                                cwd=BASE_DIR,
                                restart_on_script_change=settings.DEBUG)


class GraphQLQueryPrefetchInfo(NamedTuple):
    '''
    Encapsulates details from the server-side renderer
    about a GraphQL query that should (ideally) be