[BUG] - synchronize._semlock in python3.9 breaking multiprocessing.pool in AWS lambda which breaks OpenSearch
See original GitHub issueOSError: [Errno 38] Function not implemented. I started seeing this error after upgrading to python3.9. The reason is opensearch bulk
function is using multiprocessing module internally and python multiprocessing.pool.ThreadPool
is breaking.
OSError: [Errno 38] Function not implemented
sl = self._semlock = _multiprocessing.SemLock(
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.9/multiprocessing/synchronize.py", line 57, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.9/multiprocessing/synchronize.py", line 162, in __init__
return Lock(ctx=self.get_context())
–
It looks like:
-
synchronize.Lock doesn’t work in lambda for any version of Python (lambda has no /dev/shm, and no write access to /dev in lambda - see: https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda )
-
ThreadPool is now using synchronize.Lock from version 3.9
To Reproduce
Steps to reproduce the behavior:
- Deploy an application using
opensearch-py==1.0.0
to aws lambda - Invoke bulk function of opensearch
- See error
Expected behavior The opensearch client should work as it was working fine with python3.6
Plugins
opensearch-py==1.0.0
Screenshots Error screenshots
Host/Environment (please complete the following information):
- OS: Aws lambda
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top GitHub Comments
I’m also seeing this error with Python 3.8
Is anyone up for contributing a patch that addresses this issue when /dev/shm isn’t available? There’s a potential drop in replacement for the multiprocessing library: https://pypi.org/project/lambda-multiprocessing/