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

Fix worker to load multiple challenges in dev env #2277

Closed
wants to merge 1 commit into from

Conversation

RishabhJain2018
Copy link
Member

This PR fixes -

  1. Removes CHALLENGE_PK from docker.env file to load multiple challenges in a single worker for dev env.
  2. Add a check if a module is created or not for a challenge and then creates a module for another challenge while loading multiple challenges in dev env.

@@ -38,8 +39,8 @@
"DJANGO_SETTINGS_MODULE", "settings.dev"
)
DJANGO_SERVER = os.environ.get("DJANGO_SERVER", "localhost")
LIMIT_CONCURRENT_SUBMISSION_PROCESSING = os.environ.get(
"LIMIT_CONCURRENT_SUBMISSION_PROCESSING"
LIMIT_CONCURRENT_SUBMISSION_PROCESSING = eval(
Copy link
Member

Choose a reason for hiding this comment

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

Instead of eval(), it would definitely be a better idea to do int() since this is always going to be integer. By doing eval(), you are opening doors for bugs later in the codebase.

if isinstance(challenge_module, ModuleType):
return
else:
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

Why exiting the process? So basically what will happen here is that if the module is not loaded then the process will exit without showing any error. This doesn't sound right to me.

@@ -249,6 +250,7 @@ def extract_challenge_data(challenge, phases):
CHALLENGE_IMPORT_STRING.format(challenge_id=challenge.id)
)
EVALUATION_SCRIPTS[challenge.id] = challenge_module
return challenge_module
Copy link
Member

Choose a reason for hiding this comment

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

Sorry but I don't think I understand exactly how returning the challenge module here will help solve the problem of loading multiple modules. Can you please elaborate more on how this is solving the problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a temporary hack but I found a permanent fix for this while loading the modules dunamically: https://docs.python.org/3/library/importlib.html#importlib.invalidate_caches

@RishabhJain2018
Copy link
Member Author

Closing this PR.

@RishabhJain2018 RishabhJain2018 deleted the worker-fix-4 branch July 13, 2019 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants