[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Oct 10 13:32:07 PDT 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/46b0e30b9e8b/
Changeset:   46b0e30b9e8b
Branch:      yt
User:        MatthewTurk
Date:        2013-10-08 19:58:01
Summary:     Adding a memory checker routine.
Affected #:  1 file

diff -r a588666af47f6e39cd931225df084a8633195e14 -r 46b0e30b9e8bca6fd1b7ecc097865dd920d8a656 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -625,3 +625,22 @@
         return
     if not os.path.exists(my_dir):
         only_on_root(os.makedirs, my_dir)
+
+ at contextlib.contextmanager
+def memory_checker(interval = 15):
+    import threading
+    class MemoryChecker(threading.Thread):
+        def __init__(self, event, interval):
+            self.event = event
+            self.interval = interval
+            threading.Thread.__init__(self)
+
+        def run(self):
+            while not self.event.wait(self.interval):
+                print "MEMORY: %0.3e gb" % (get_memory_usage()/1024.)
+
+    e = threading.Event()
+    mem_check = MemoryChecker(e, interval)
+    mem_check.start()
+    yield
+    e.set()


https://bitbucket.org/yt_analysis/yt/commits/e3ed19b1d4f0/
Changeset:   e3ed19b1d4f0
Branch:      yt
User:        MatthewTurk
Date:        2013-10-10 21:11:59
Summary:     Adding docstring.
Affected #:  1 file

diff -r 46b0e30b9e8bca6fd1b7ecc097865dd920d8a656 -r e3ed19b1d4f03c5a0b4172087e63972c6689cbc0 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -628,6 +628,22 @@
 
 @contextlib.contextmanager
 def memory_checker(interval = 15):
+    r"""This is a context manager that monitors memory usage.
+
+    Parameters
+    ----------
+    interval : int
+        The number of seconds between printing the current memory usage in
+        gigabytes of the current Python interpreter.
+
+    Examples
+    --------
+
+    >>> with memory_checker(10):
+    ...     arr = np.zeros(1024*1024*1024, dtype="float64")
+    ...     time.sleep(15)
+    ...     del arr
+    """
     import threading
     class MemoryChecker(threading.Thread):
         def __init__(self, event, interval):


https://bitbucket.org/yt_analysis/yt/commits/6c5f960c9ff8/
Changeset:   6c5f960c9ff8
Branch:      yt
User:        ngoldbaum
Date:        2013-10-10 22:32:00
Summary:     Merged in MatthewTurk/yt (pull request #614)

Adding a memory checker routine.
Affected #:  1 file

diff -r 725c3037c6e7be96c5eff3c67103993251a36650 -r 6c5f960c9ff820500849f9f0095d8f152a5cda80 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -625,3 +625,38 @@
         return
     if not os.path.exists(my_dir):
         only_on_root(os.makedirs, my_dir)
+
+ at contextlib.contextmanager
+def memory_checker(interval = 15):
+    r"""This is a context manager that monitors memory usage.
+
+    Parameters
+    ----------
+    interval : int
+        The number of seconds between printing the current memory usage in
+        gigabytes of the current Python interpreter.
+
+    Examples
+    --------
+
+    >>> with memory_checker(10):
+    ...     arr = np.zeros(1024*1024*1024, dtype="float64")
+    ...     time.sleep(15)
+    ...     del arr
+    """
+    import threading
+    class MemoryChecker(threading.Thread):
+        def __init__(self, event, interval):
+            self.event = event
+            self.interval = interval
+            threading.Thread.__init__(self)
+
+        def run(self):
+            while not self.event.wait(self.interval):
+                print "MEMORY: %0.3e gb" % (get_memory_usage()/1024.)
+
+    e = threading.Event()
+    mem_check = MemoryChecker(e, interval)
+    mem_check.start()
+    yield
+    e.set()

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list