Context manager for the import lock.
| 1219 | # Import itself ############################################################### |
| 1220 | |
| 1221 | class _ImportLockContext: |
| 1222 | |
| 1223 | """Context manager for the import lock.""" |
| 1224 | |
| 1225 | def __enter__(self): |
| 1226 | """Acquire the import lock.""" |
| 1227 | _imp.acquire_lock() |
| 1228 | |
| 1229 | def __exit__(self, exc_type, exc_value, exc_traceback): |
| 1230 | """Release the import lock regardless of any raised exceptions.""" |
| 1231 | _imp.release_lock() |
| 1232 | |
| 1233 | |
| 1234 | def _resolve_name(name, package, level): |