Skip to content

Commit

Permalink
Ensure that karabo-bridge-monitor triggers garbage collection after e…
Browse files Browse the repository at this point in the history
…ach message
  • Loading branch information
takluyver committed Feb 20, 2019
1 parent 80a2361 commit ef58006
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions karabo_bridge/cli/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Monitor messages coming from Karabo bridge."""

import argparse
import gc

from .glimpse import print_one_train
from ..client import Client
Expand All @@ -24,8 +25,14 @@ def main(argv=None):
if args.ntrains is None:
while True:
print_one_train(client, verbosity=args.verbose)
# Explicitly trigger garbage collection,
# seems to be needed to avoid using lots of memory.
gc.collect()
else:
for _ in range(args.ntrains):
print_one_train(client, verbosity=args.verbose)
# Explicitly trigger garbage collection,
# seems to be needed to avoid using lots of memory.
gc.collect()
except KeyboardInterrupt:
print('\nexit.')

0 comments on commit ef58006

Please sign in to comment.