Skip to content

ThreadPool() is not supported on AWS Lambda using Python 3.7 and above  #1

@mdw123

Description

@mdw123

We use docspring for filling out documents in our event-driven python system that runs within AWS Lambdas.

Recently, when upgrading from Python 3.6, your component started failing with the following callstack:

File "/var/task/api/external/docspring_api.py", line 10, in __init__     self._client = docspring.Client()   
File "/var/task/docspring/api/pdf_api.py", line 32, in __init__     api_client = ApiClient()   
File "/var/task/docspring/api_client.py", line 68, in __init__     self.pool = ThreadPool()   
File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 925, in __init__    Pool.__init__(self, processes, initializer, initargs)   
File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 196, in __init__     self._change_notifier = self._ctx.SimpleQueue()   
File "/var/lang/lib/python3.8/multiprocessing/context.py", line 113, in SimpleQueue     return SimpleQueue(ctx=self.get_context())   
File "/var/lang/lib/python3.8/multiprocessing/queues.py", line 336, in __init__     self._rlock = ctx.Lock()   
File "/var/lang/lib/python3.8/multiprocessing/context.py", line 68, in Lock     return Lock(ctx=self.get_context())   File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 162, in __init__     SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)   
File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 57, in __init__     sl = self._semlock = _multiprocessing.SemLock( OSError: [Errno 38] Function not implemented

This occurs because the lambda execution environment does not support shared memory.

More: https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions