pytest-services icon indicating copy to clipboard operation
pytest-services copied to clipboard

Hang when trying to run Xvfb

Open The-Compiler opened this issue 10 years ago • 4 comments

I tried a minimal testcase using Xvfb:

import faulthandler
import signal
import pytest


faulthandler.register(signal.SIGUSR1)


@pytest.fixture(scope='session')
def run_services():
    return True


def test_foo(xvfb):
    pass

unfortunately that hangs using 100% CPU here:

  File "/home/florian/.venv/lib/python3.4/genericpath.py", line 19 in exists
  File "/home/florian/.venv/local/lib/python3.4/site-packages/pytest_services/locks.py", line 171 in get_display
  File "/home/florian/.venv/local/lib/python3.4/site-packages/pytest_services/locks.py", line 132 in lock_resource
  File "/home/florian/.venv/local/lib/python3.4/site-packages/pytest_services/locks.py", line 176 in get_free_display
  File "/home/florian/.venv/local/lib/python3.4/site-packages/pytest_services/locks.py", line 198 in get_display
  File "/home/florian/.venv/local/lib/python3.4/site-packages/pytest_services/xvfb.py", line 25 in xvfb_display
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1960 in call_fixture_func
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 2039 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1578 in _getfuncargvalue
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1532 in _get_active_fixturedef
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 2001 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1578 in _getfuncargvalue
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1532 in _get_active_fixturedef
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1515 in getfuncargvalue
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1472 in _fillfixtures
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 789 in fillfixtures
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/python.py", line 1324 in setup
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 403 in prepare
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 86 in pytest_runtest_setup
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 596 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 264 in __init__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 247 in _wrapped_call
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 595 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 333 in <lambda>
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 338 in _hookexec
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 724 in __call__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 137 in <lambda>
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 149 in __init__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 137 in call_runtest_hook
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 119 in call_and_report
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 72 in runtestprotocol
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/runner.py", line 65 in pytest_runtest_protocol
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 596 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 264 in __init__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 247 in _wrapped_call
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 595 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 333 in <lambda>
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 338 in _hookexec
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 724 in __call__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/main.py", line 146 in pytest_runtestloop
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 596 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 333 in <lambda>
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 338 in _hookexec
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 724 in __call__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/main.py", line 121 in _main
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/main.py", line 90 in wrap_session
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/main.py", line 115 in pytest_cmdline_main
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 596 in execute
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 333 in <lambda>
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 338 in _hookexec
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py", line 724 in __call__
  File "/home/florian/.venv/local/lib/python3.4/site-packages/_pytest/config.py", line 48 in main
  File "./.venv/bin/py.test", line 11 in <module>

I sampled the stack a few times using faulthandler, and it's either in there or without the first line, in get_display.

This is on Debian Jessie with pytest==2.8.0, pytest-services==1.1.11 and xvfb 2:1.17.2-2, running without xdist. There are no locks in /tmp.

The-Compiler avatar Oct 07 '15 14:10 The-Compiler

thanks for the report will check

bubenkoff avatar Oct 07 '15 20:10 bubenkoff

FWIW using xvfbwrapper from #4 worked fine on the same system, and seems easier for my usecase: https://github.com/The-Compiler/qutebrowser/commit/52ced6c652e1b93ab9cf091c982ce077fd09bf89

The-Compiler avatar Oct 07 '15 20:10 The-Compiler

well, i can't say i like your solution with configure hooks - simply no reason to use them generator session scoped fixture would be a solution may be you can submit a PR implementing #4?

bubenkoff avatar Oct 07 '15 20:10 bubenkoff

generator session scoped fixture would be a solution

That was my first approach, but it didn't work - the qapp session-scope fixture from pytest-qt was created before the xvfb fixture, and Qt seems to get the DISPLAY when creating the QApplication.

may be you can submit a PR implementing #4?

I'm afraid I'm too busy with other stuff to do that, sorry!

The-Compiler avatar Oct 07 '15 20:10 The-Compiler