Created
March 29, 2017 11:11
-
-
Save vilos/66638f6ee80518a2c0e78f81762d1a4d to your computer and use it in GitHub Desktop.
demonstrate memory leak in circuits bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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