Asana / python-asana

Official Python client library for the Asana API v1
MIT License
303 stars 105 forks source link

Handle multiprocessing.pool.ThreadPool init on OS without shared memory for processes #179

Closed olegy-ait closed 1 year ago

olegy-ait commented 1 year ago

AWS Lambda does not support multiprocessing.Queue or multiprocessing.Pool therefore the lib cannot init ThreadPool on Lambda. This commit adds a possibility do not init ThreadPool if the OS does not support ThreadPool (shared memory for processes). As far as async_req is disabled by default no need to change other functions.

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

jv-asana commented 1 year ago

Hi @olegy-ait, these changes look good but can you move these change into the api_client.mustache file instead of the api_client.py file.

The reason why is because each time we deploy/build a new release version, the generator we use references the api_client.mustache file to build the api_client.py file. Ideally we want the changes to be in one place and also to prevent future merge conflicts or code changes made directly to api_client.py from being overwritten by the generator + api_client.mustache template

jv-asana commented 1 year ago

@olegy-ait Let me know if you need help or want me to do this. And I forgot to mention this in my previous comment but thanks for contributing :)

olegy-ait commented 1 year ago

Thanks for the feedback @jv-asana! Will update the PR by next few days

olegy-ait commented 1 year ago

Hi @jv-asana! I have updated the PR to use api_client.mustache. Could you please check?

jv-asana commented 1 year ago

@olegy-ait I should probably document this in the README.md but in case you were wondering how to test the changes you've made to api_client.mustache locally you can follow these instructions I've put here:

https://github.com/Asana/python-asana/issues/175#issuecomment-1678117727