Show More
@@ -20,6 +20,7 b' import errno, shutil, sys, tempfile, tra' | |||||
20 | import re as remod |
|
20 | import re as remod | |
21 | import os, time, datetime, calendar, textwrap, signal, collections |
|
21 | import os, time, datetime, calendar, textwrap, signal, collections | |
22 | import imp, socket, urllib |
|
22 | import imp, socket, urllib | |
|
23 | import gc | |||
23 |
|
24 | |||
24 | if os.name == 'nt': |
|
25 | if os.name == 'nt': | |
25 | import windows as platform |
|
26 | import windows as platform | |
@@ -544,6 +545,28 b' def always(fn):' | |||||
544 | def never(fn): |
|
545 | def never(fn): | |
545 | return False |
|
546 | return False | |
546 |
|
547 | |||
|
548 | def nogc(func): | |||
|
549 | """disable garbage collector | |||
|
550 | ||||
|
551 | Python's garbage collector triggers a GC each time a certain number of | |||
|
552 | container objects (the number being defined by gc.get_threshold()) are | |||
|
553 | allocated even when marked not to be tracked by the collector. Tracking has | |||
|
554 | no effect on when GCs are triggered, only on what objects the GC looks | |||
|
555 | into. As a workaround, disable GC while building complexe (huge) | |||
|
556 | containers. | |||
|
557 | ||||
|
558 | This garbage collector issue have been fixed in 2.7. | |||
|
559 | """ | |||
|
560 | def wrapper(*args, **kwargs): | |||
|
561 | gcenabled = gc.isenabled() | |||
|
562 | gc.disable() | |||
|
563 | try: | |||
|
564 | return func(*args, **kwargs) | |||
|
565 | finally: | |||
|
566 | if gcenabled: | |||
|
567 | gc.enable() | |||
|
568 | return wrapper | |||
|
569 | ||||
547 | def pathto(root, n1, n2): |
|
570 | def pathto(root, n1, n2): | |
548 | '''return the relative path from one place to another. |
|
571 | '''return the relative path from one place to another. | |
549 | root should use os.sep to separate directories |
|
572 | root should use os.sep to separate directories |
General Comments 0
You need to be logged in to leave comments.
Login now