Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues when using jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration)) on AWS Lambda #50

Open
maneskiivan opened this issue Mar 4, 2021 · 3 comments

Comments

@maneskiivan
Copy link

maneskiivan commented Mar 4, 2021

Hello,

I am able to use the script below successfully when deployed locally on my computer:

configuration = jcapiv1.Configuration() configuration.api_key['x-api-key'] = jumpcloud_apikey # create an instance of the API class api_instance = jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration)) content_type = 'application/json' # str | (default to application/json) accept = 'application/json' # str | (default to application/json) x_org_id = jumpcloud_org_id # str | (optional) (default to ) body = jcapiv1.Systemuserputpost( email='[email protected]', username='jdoe', firstname='John', lastname='Doe' ) api_response = api_instance.systemusers_post(content_type, accept, body=body, x_org_id=x_org_id)

When I use the script on AWS Lambda I get the following error:

{
"errorMessage": "[Errno 38] Function not implemented",
"errorType": "OSError",
"stackTrace": [
" File "/var/task/lambda_function.py", line 17, in lambda_handler\n api_instance = jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration))\n",
" File "/opt/python/lib/python3.8/site-packages/jcapiv1/api_client.py", line 69, in init\n self.pool = ThreadPool()\n",
" File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 925, in init\n Pool.init(self, processes, initializer, initargs)\n",
" File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 196, in init\n self._change_notifier = self._ctx.SimpleQueue()\n",
" File "/var/lang/lib/python3.8/multiprocessing/context.py", line 113, in SimpleQueue\n return SimpleQueue(ctx=self.get_context())\n",
" File "/var/lang/lib/python3.8/multiprocessing/queues.py", line 336, in init\n self._rlock = ctx.Lock()\n",
" File "/var/lang/lib/python3.8/multiprocessing/context.py", line 68, in Lock\n return Lock(ctx=self.get_context())\n",
" File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 162, in init\n SemLock.init(self, SEMAPHORE, 1, 1, ctx=ctx)\n",
" File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 57, in init\n sl = self._semlock = _multiprocessing.SemLock(\n"
]
}

I found some article that suggest I should use the multiprocessing library to handle this issue. I tried resolving this with that library with no success.

Any help would be greatly appreciated.

Thank you.

@maneskiivan
Copy link
Author

I forked the library and removed the multiprocessing parts all together. That resolved the issue.

@chad-larsen-rapid
Copy link

@maneskiivan, do you recall which parts you removed from your fork? I'm running into the same issue and hoping to follow your steps.

@maneskiivan
Copy link
Author

@chad-larsen-rapid ,
You have to remove lines in this file:
https://github.com/TheJumpCloud/jcapi-python/blob/master/jcapiv1/jcapiv1/api_client.py
If you are using v2 do the same there.
Lines to remove:
17
from multiprocessing.pool import ThreadPool
69
self.pool = ThreadPool()
78 - 80
def del(self):
self.pool.close()
self.pool.join()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants