mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
17 lines
451 B
Python
17 lines
451 B
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
import contextlib
|
|
import sys
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def DlopenGuard():
|
|
# In python 2.7 required constants are not defined.
|
|
# Thus they are listed explicitly
|
|
flags = sys.getdlopenflags()
|
|
sys.setdlopenflags(256 | 2) # RTLD_GLOBAL | RTLD_NOW
|
|
yield
|
|
sys.setdlopenflags(flags)
|