Skip to content

Instantly share code, notes, and snippets.

@vilos
Created March 29, 2017 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vilos/66638f6ee80518a2c0e78f81762d1a4d to your computer and use it in GitHub Desktop.
Save vilos/66638f6ee80518a2c0e78f81762d1a4d to your computer and use it in GitHub Desktop.
demonstrate memory leak in circuits bridge
#!/usr/bin/env python
from __future__ import print_function
from os import getpid
from circuits import ipc, Event, Component, Timer
import resource
class hello(Event):
"""hello Event"""
def get_memory(name):
return '{} memory: {}'.format(name, resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
class Child(Component):
def hello(self, msg):
print(msg[:50])
print(get_memory('child'))
return "Hello from child with pid {0} ".format(getpid()) + "#" * 1024 * 1024
class App(Component):
def init(self):
Child().start(process=True, link=self)
def ready(self, *args):
Timer(1, hello(), persist=True).register(self)
def hello(self):
msg = "Hello from parent with pid {0} ".format(self.pid) + "#" * 1024 * 1024
y = yield self.call(ipc(hello(msg)))
yield print(str(y)[:50])
print(get_memory('parent'))
App().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment