Ejemplo n.º 1
0
 def __init__(self, lock_path, lock_file_prefix="WebKitHttpd.lock.", guard_lock="WebKit.lock", filesystem=None, executive=None):
     self._executive = executive or Executive()
     self._filesystem = filesystem or FileSystem()
     self._lock_path = lock_path
     if not self._lock_path:
         # FIXME: FileSystem should have an accessor for tempdir()
         self._lock_path = tempfile.gettempdir()
     self._lock_file_prefix = lock_file_prefix
     self._lock_file_path_prefix = self._filesystem.join(self._lock_path, self._lock_file_prefix)
     self._guard_lock_file = self._filesystem.join(self._lock_path, guard_lock)
     self._guard_lock = FileLock(self._guard_lock_file)
     self._process_lock_file_name = ""
Ejemplo n.º 2
0
 def __init__(self,
              lock_path,
              lock_file_prefix="WebKitHttpd.lock.",
              guard_lock="WebKit.lock"):
     self._lock_path = lock_path
     if not self._lock_path:
         self._lock_path = tempfile.gettempdir()
     self._lock_file_prefix = lock_file_prefix
     self._lock_file_path_prefix = os.path.join(self._lock_path,
                                                self._lock_file_prefix)
     self._guard_lock_file = os.path.join(self._lock_path, guard_lock)
     self._guard_lock = FileLock(self._guard_lock_file)
     self._process_lock_file_name = ""
     self._executive = Executive()
Ejemplo n.º 3
0
 def _next_free_display(self):
     running_pids = self._port.host.executive.run_command(
         ['ps', '-eo', 'comm,command'])
     reserved_screens = set()
     for pid in running_pids.split('\n'):
         match = re.match('(X|Xvfb|Xorg)\s+.*\s:(?P<screen_number>\d+)',
                          pid)
         if match:
             reserved_screens.add(int(match.group('screen_number')))
     for i in range(99):
         if i not in reserved_screens:
             _guard_lock_file = self._port.host.filesystem.join(
                 '/tmp', 'WebKitXvfb.lock.%i' % i)
             self._guard_lock = FileLock(_guard_lock_file)
             if self._guard_lock.acquire_lock():
                 return i
Ejemplo n.º 4
0
 def setUp(self):
     self._lock_name = "TestWebKit" + str(os.getpid()) + ".lock"
     self._lock_path = os.path.join(tempfile.gettempdir(), self._lock_name)
     self._file_lock1 = FileLock(self._lock_path, 0.1)
     self._file_lock2 = FileLock(self._lock_path, 0.1)