title: Multiprocessing.Lock not available in Python run in AWS Lambda
body: <p>I have an object that caches some AWS SSM Parameters. I wanted to implement this class multiprocessor safe. But in an AWS Lambda Python environment <code>/dev/shm/</code> is not available so I get the following error:</p>
  
  <pre><code>[ERROR] OSError: [Errno 38] Function not implemented
  </code></pre>
  
  <p>The error occurs on the line where the <code>Lock</code> is initialized.
  Here is the code for the cache class:</p>
  
  <pre><code>from multiprocessing import Lock
  
  
  class CachedRetriever:  # pylint: disable=too-few-public-methods
      """
      CachedRetriever uses a local dictionary cache to store results.
      If there is a cache hit the result is immediately returned.
      The Cache never expires and does not have a limited size.
      """
  
      def __init__(self):
          self.__cache = {}
          self.__cache_lock = Lock()
  
      def cached_get(self, key: str, function, **kwargs):
          """
          Get using the cache or store it in the cache.
          :param key: The key of the cached value
          :param function: The function which has to be executed
          :param kwargs: The arguments which will be used by the function
          :return:
          """
          if key not in self.__cache:
              with self.__cache_lock:
                  if key not in self.__cache:
                      self.__cache[key] = function(**kwargs)
  
          return self.__cache[key]
  </code></pre>
  
  <p>What is a multiprocessing safe way to implement this class that can run using the limited multiprocessing types in aws python?</p>
  
  <p>See for additional information:
  <a href="https://forums.aws.amazon.com/thread.jspa?threadID=219962" rel="nofollow noreferrer">https://forums.aws.amazon.com/thread.jspa?threadID=219962</a></p>