MCPcopy
hub / github.com/celery/celery / read_pid

Method read_pid

celery/platforms.py:163–176  ·  view source on GitHub ↗

Read and return the current pid.

(self)

Source from the content-addressed store, hash-verified

161 __exit__ = release
162
163 def read_pid(self):
164 """Read and return the current pid."""
165 with ignore_errno('ENOENT'):
166 with open(self.path) as fh:
167 line = fh.readline()
168 if line.strip() == line: # must contain '\n'
169 raise ValueError(
170 f'Partial or invalid pidfile {self.path}')
171
172 try:
173 return int(line.strip())
174 except ValueError:
175 raise ValueError(
176 f'pidfile {self.path} contents invalid.')
177
178 def remove(self):
179 """Remove the lock."""

Callers 8

test_read_pidMethod · 0.95
remove_if_staleMethod · 0.95
_create_pidlockFunction · 0.95
pidMethod · 0.45

Calls 3

ignore_errnoFunction · 0.85
openFunction · 0.85
readlineMethod · 0.80