Commit 88c77110 authored by Jason R. Coombs's avatar Jason R. Coombs

Replace global variable serving as an implicit cache with an explicit 'once' decorator.

parent 827c4c36
......@@ -2,6 +2,7 @@ import os
import socket
import atexit
import re
import functools
from setuptools.extern.six.moves import urllib, http_client, map, filter
......@@ -204,14 +205,18 @@ def opener_for(ca_bundle=None):
).open
_wincerts = None
# from jaraco.functools
def once(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not hasattr(func, 'always_returns'):
func.always_returns = func(*args, **kwargs)
return func.always_returns
return wrapper
@once
def get_win_certfile():
global _wincerts
if _wincerts is not None:
return _wincerts.name
try:
from wincertstore import CertFile
except ImportError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment