-
-
Notifications
You must be signed in to change notification settings - Fork 147
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 problem with non-exported function #603
fix problem with non-exported function #603
Conversation
lib/quantum.ex
Outdated
@@ -343,7 +343,7 @@ defmodule Quantum do | |||
|
|||
defp invalid_job_task?(%Job{task: {m, f, args}}) | |||
when is_atom(m) and is_atom(f) and is_list(args), | |||
do: not function_exported?(m, f, length(args)) | |||
do: not (Code.ensure_loaded?(m) && function_exported?(m, f, length(args))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is quite hard to read. Can we switch it to something like this?
if Code.ensure_loaded?(m),
do: not(function_exported?(m, f, length(args))),
else: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, it's definitely more readable that way. Also, thank you for reacting so quickly! 🙏
Pull Request Test Coverage Report for Build 7047ec21deddb8daa1a64b6a04869c7a6d3fa56b-PR-603Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Thank you! :) |
We had a problem where Quantum could only schedule a job right after executing
mix clean
, but with every call tomix
after that, our configured jobs were not scheduled, becausefunction_exported?/3
returned false, even though the function still existed, but apparently was not yet exported at the time the Quantum code executed. This PR fixes this by callingCode.ensure_loaded?/1
beforefunction_exported?/3
, which actively tries to load the module before returningtrue
if this was successful orfalse
otherwise (e.g. if the module does not exist).