Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http_timeout test is flaky #12

Open
raylu opened this issue Jun 12, 2017 · 4 comments
Open

http_timeout test is flaky #12

raylu opened this issue Jun 12, 2017 · 4 comments

Comments

@raylu
Copy link
Contributor

raylu commented Jun 12, 2017

on 6e18977,

debian:~/src/asks/tests$ pytest --verbose --tb=native
=============================================== test session starts ================================================
platform linux -- Python 3.6.1+, pytest-3.1.2, py-1.4.34, pluggy-0.4.0 -- /home/raylu/env/bin/python3.6
cachedir: ../.cache
rootdir: /home/raylu/src/asks, inifile:
collected 25 items 

test_asks.py::test_https_get PASSED
test_asks.py::test_bad_www_and_schema_get PASSED
test_asks.py::test_https_get_alt PASSED
test_asks.py::test_http_get PASSED
test_asks.py::test_http_redirect PASSED
test_asks.py::test_http_max_redirect_error PASSED
test_asks.py::test_http_max_redirect PASSED
test_asks.py::test_http_timeout_error PASSED
test_asks.py::test_http_timeout FAILED
test_asks.py::test_param_dict_set PASSED
test_asks.py::test_data_dict_set PASSED
test_asks.py::test_cookie_dict_send PASSED
test_asks.py::test_header_set PASSED
test_asks.py::test_file_send_single PASSED
test_asks.py::test_file_send_double PASSED
test_asks.py::test_file_and_data_send PASSED
test_asks.py::test_json_send PASSED
test_asks.py::test_gzip PASSED
test_asks.py::test_deflate PASSED
test_asks.py::test_chunked_te PASSED
test_asks.py::test_stream PASSED
test_asks.py::test_callback PASSED
test_asks.py::test_hsession_smallpool PASSED
test_asks.py::test_session_stateful PASSED
test_asks.py::test_Session_smallpool PASSED

===================================================== FAILURES =====================================================
________________________________________________ test_http_timeout _________________________________________________
Traceback (most recent call last):
  File "/home/raylu/src/asks/asks/sessions.py", line 156, in request
    timeout, response_task.join())
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 730, in _timeout_after_func
    return await coro
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 110, in join
    await self.wait()
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 121, in wait
    await _scheduler_wait(self.joining, 'TASK_JOIN')
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/traps.py", line 110, in _scheduler_wait
    yield (_trap_sched_wait, sched, state)
curio.errors.TaskTimeout: 34329.550673733

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/kernel.py", line 835, in _run_coro
    trap = current._send(current.next_value)
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 96, in _task_runner
    return await coro
  File "/home/raylu/src/asks/tests/test_asks.py", line 73, in test_http_timeout
    r = await asks.get('http://httpbin.org/delay/1', timeout=2)
  File "/home/raylu/src/asks/asks/base_funcs.py", line 29, in request
    r = await s.request(method, url=uri, **kwargs)
  File "/home/raylu/src/asks/asks/sessions.py", line 159, in request
    raise RequestTimeout
asks.errors.RequestTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/raylu/src/asks/tests/test_asks.py", line 11, in func_wrapper
    return curio.run(func(*args, **kwargs))
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/kernel.py", line 882, in run
    return kernel.run(corofunc, *args, timeout=timeout)
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/kernel.py", line 214, in run
    raise TaskError('Task Crashed') from ret_exc
curio.errors.TaskError: Task Crashed
----------------------------------------------- Captured stderr call -----------------------------------------------
Task 27 crashed
Traceback (most recent call last):
  File "/home/raylu/src/asks/asks/sessions.py", line 156, in request
    timeout, response_task.join())
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 730, in _timeout_after_func
    return await coro
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 110, in join
    await self.wait()
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 121, in wait
    await _scheduler_wait(self.joining, 'TASK_JOIN')
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/traps.py", line 110, in _scheduler_wait
    yield (_trap_sched_wait, sched, state)
curio.errors.TaskTimeout: 34329.550673733

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/kernel.py", line 835, in _run_coro
    trap = current._send(current.next_value)
  File "/home/raylu/env/lib/python3.6/site-packages/curio-0.7-py3.6.egg/curio/task.py", line 96, in _task_runner
    return await coro
  File "/home/raylu/src/asks/tests/test_asks.py", line 73, in test_http_timeout
    r = await asks.get('http://httpbin.org/delay/1', timeout=2)
  File "/home/raylu/src/asks/asks/base_funcs.py", line 29, in request
    r = await s.request(method, url=uri, **kwargs)
  File "/home/raylu/src/asks/asks/sessions.py", line 159, in request
    raise RequestTimeout
asks.errors.RequestTimeout
======================================= 1 failed, 24 passed in 18.39 seconds =======================================
Task(id=97, name='session_t_smallpool', <coroutine object session_t_smallpool at 0x7f9e6c50f678>, state='TERMINATED') never joined

rerunning immediately passed

@theelous3
Copy link
Owner

theelous3 commented Jun 12, 2017

I suppose even httpbin.org can be flaky.

All of the tests running on live servers in the wild means now and then one will fail but a repeat will pass. Not ideal but a hell of a lot more convenient than writing test server(s) with all of the behaviours required.

(302 response on non-www prefaced requests to a domain, for example.)

@njsmith
Copy link
Contributor

njsmith commented Jun 14, 2017

It's possible to pip install httpbin and run it locally as part of your test suite.

@raylu
Copy link
Contributor Author

raylu commented Sep 15, 2017

I believe pytest-dev/pytest#2267 currently makes it tricky to use https://github.com/kevin1024/pytest-httpbin

@raylu
Copy link
Contributor Author

raylu commented Sep 16, 2017

through the magic of class-based fixtures, I have sidestepped the reflection problem in #37

assuming that gets merged, now we just need to find a replacement for the remaining 3 tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants