-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix orjson loading error
#4562
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 orjson loading error
#4562
Conversation
| logger.exception(msg) | ||
| return sys.modules.get(name, None) | ||
|
|
||
| else: |
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.
The else is not necessary after return.
T4rk1n
left a comment
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.
💃
alexcjohnson
left a comment
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.
💃 very nice diagnosis & fix!
|
Some tests are failing on CI. |
Closes #3567
Also addresses plotly/dash#2797
Summary
Address the error described in #3567 by adjusting the module loading logic in
get_module.The error can be reproduced by following these steps.
As best I can tell, the error is caused by a race condition between the multiple threads in the Flask hot reloader, and the fact that Python adds a module to
sys.modulesbefore the module has been executed [1] [2]. If one thread attempts to loadorjsonafter it has been added tosys.modulesbut before it has been executed, we'll get the error.Fix
get_moduleso that whenshould_load=True, we just callimport_moduleright away instead of checkingsys.modulesfirst.import_modulecontains logic to verify that the module is fully initializedshould_load=Falseremains the same: If the module is insys.moduleswe return it, otherwise we returnNoneCode PR
plotly.graph_objects, my modifications concern thecodegenfiles and not generated files.modified existing tests.
new tutorial notebook (please see the doc checklist as well).