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

pytest-server-fixtures: Support large pids in xvfb #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pytest-server-fixtures/pytest_server_fixtures/xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class XvfbServer(object):

def __init__(self):
tmpdir = mkdtemp(prefix='XvfbServer.', dir=Workspace.get_base_tempdir())
for servernum in range(os.getpid(), 65536):
pid_max = 65536
with open('/proc/sys/kernel/pid_max') as pid_max_file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this guaranteed to exist on all Linux distributions? We should probably safely fall back to 65536 if the file doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do fall back, it's set before we open the /proc file. That /proc file was added sometime in 2.5, so it should exist, but it may throw an exception if /proc isn't mounted -- but we probably have bigger problems in that case.

pid_max = int(pid_max_file.read())
for servernum in range(os.getpid(), pid_max):
if os.path.exists('/tmp/.X{0}-lock'.format(servernum)):
continue
self.display = ':' + str(servernum)
Expand Down