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

Run cloudcustodian from python with arguments #8464

Merged
merged 2 commits into from Apr 12, 2023

Conversation

gdisantis24
Copy link
Contributor

Hello,
Currently I'm running cloudcustodian in a multi-thread environment (3 parallel execution).
To do that I'm setting:

from c7n.cli import main

def th_function(region):
      args = [
          "cc_runner",
          "run",
          "--help",
          "--region",
          region
      ]
      sys.argv = args
      main()

However I believe that multiple threads are accessing/editing sys.argv at the same time, so that's why cloud custodian sometimes is running on the same region. With my PR it's possible to run it without occurring in this problem in this way:

from c7n.cli import main
main(["run", "--help"])

@gdisantis24 gdisantis24 requested a review from kapilt as a code owner April 5, 2023 07:40
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 5, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: gdisantis24 / name: Giovanni Di Santi (2b9309b)

@kapilt
Copy link
Collaborator

kapilt commented Apr 5, 2023

we provide a parallel execution tool in c7n-org, we do internal thread parallelism as well which c7n-org is designed to work with, we do make use of thread locals, so using a naive threading wrapper has some peril. we don't really provide a stable api for use as a library vs a command line tool. that said the change seems innocuous, albeit please sign the linux foundation /cncf cla for further consideration. direct link

@gdisantis24
Copy link
Contributor Author

Hello @kapilt , I signed the document!

Copy link
Collaborator

@kapilt kapilt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kapilt kapilt merged commit 2dbb682 into cloud-custodian:main Apr 12, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants