Skip to content

Commit

Permalink
Patch os.chdir to raise an exception, once twistd is done with it
Browse files Browse the repository at this point in the history
Fixes #1007
  • Loading branch information
Dustin J. Mitchell committed Oct 4, 2010
1 parent eff7865 commit 4f6d211
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion master/buildbot/master.py
Expand Up @@ -15,8 +15,8 @@
from twisted.application.internet import TimerService

import buildbot
# sibling imports
from buildbot.util import now, safeTranslate, eventual
from buildbot.util import monkeypatches
from buildbot.pbutil import NewCredPerspective
from buildbot.process.builder import Builder, IDLE
from buildbot.status.builder import Status, BuildSetStatus
Expand Down Expand Up @@ -571,6 +571,10 @@ def startService(self):
b.builder_status.addPointEvent(["master", "started"])
b.builder_status.saveYourself()

# now that we're running a master, don't use os.chdir. Note that this
# will trip up twistd if we do it any earlier
monkeypatches.disable_os_chdir()

def _handleSIGHUP(self, *args):
reactor.callLater(0, self.loadTheConfigFile)

Expand Down
6 changes: 6 additions & 0 deletions master/buildbot/util/monkeypatches.py
@@ -1,5 +1,11 @@
import os
from twisted.trial import unittest

def disable_os_chdir():
def DoNotUseOsChDir(_):
raise ValueError('Do not use os.chdir() in your code. You probably want to use path=foo or cwd=foo argument when calling out subprocesses instead')
os.chdir = DoNotUseOsChDir

def add_debugging_monkeypatches():
"""
DO NOT CALL THIS DIRECTLY
Expand Down

0 comments on commit 4f6d211

Please sign in to comment.