-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
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.
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.
💃
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.modules
before the module has been executed [1] [2]. If one thread attempts to loadorjson
after it has been added tosys.modules
but before it has been executed, we'll get the error.Fix
get_module
so that whenshould_load=True
, we just callimport_module
right away instead of checkingsys.modules
first.import_module
contains logic to verify that the module is fully initializedshould_load=False
remains the same: If the module is insys.modules
we return it, otherwise we returnNone
Code PR
plotly.graph_objects
, my modifications concern thecodegen
files and not generated files.modified existing tests.
new tutorial notebook (please see the doc checklist as well).