Skip to content

Commit 623390d

Browse files
committed
Fix #228
1 parent a0c45dd commit 623390d

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

mrq/worker.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,21 @@ def greenlet_paused_queues(self):
227227
time.sleep(self.config["paused_queues_refresh_interval"])
228228

229229
def get_memory(self):
230-
mmaps = self.process.memory_maps()
231-
mem = {
232-
"rss": sum([x.rss for x in mmaps]),
233-
"swap": sum([getattr(x, 'swap', getattr(x, 'swapped', 0)) for x in mmaps])
234-
}
235-
mem["total"] = mem["rss"] + mem["swap"]
236-
return mem
230+
231+
try:
232+
233+
mmaps = self.process.memory_maps()
234+
mem = {
235+
"rss": sum([x.rss for x in mmaps]),
236+
"swap": sum([getattr(x, 'swap', getattr(x, 'swapped', 0)) for x in mmaps])
237+
}
238+
mem["total"] = mem["rss"] + mem["swap"]
239+
return mem
240+
241+
# memory_maps is unavailable on macOS
242+
# https://github.com/pricingassistant/mrq/issues/228
243+
except Exception as e:
244+
return {"total": 0, "rss": 0, "swap": 0}
237245

238246
def get_worker_report(self, with_memory=False):
239247
""" Returns a dict containing all the data we can about the current status of the worker and

0 commit comments

Comments
 (0)