equal
deleted
inserted
replaced
18 import error, osutil, encoding |
18 import error, osutil, encoding |
19 import errno, shutil, sys, tempfile, traceback |
19 import errno, shutil, sys, tempfile, traceback |
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 |
26 else: |
27 else: |
27 import posix as platform |
28 import posix as platform |
542 return True |
543 return True |
543 |
544 |
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 |
550 n1 should use os.sep to separate directories |
573 n1 should use os.sep to separate directories |
551 n2 should use "/" to separate directories |
574 n2 should use "/" to separate directories |