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
Use of global variables #107
Comments
Moved definition of discardElements at the beginning. |
Thanks for your quick response, but I don't think that will fix it. That will stop the error message, but it won't fix the underlying problem: on Windows, the global namespace of the parent process is not shared with the subprocesses. Instead, the module is re-executed, getting a new global namespace for each subprocess. So all the modifications to I'm looking at doing a real fix. This would mean that the various options are no longer stored in separate global variables (or as properties of the |
These are really just global constants. They are not modified in the subprocesses. |
It's not a matter of whether they're modified in the subprocess. It's a matter of whether they're modified in code that does not run in the subproces. The point is that the subprocess does not see the parent module's global state. Any modifications made from within Here's a simple example to illustrate what I mean:
On Windows, the output is:
It doesn't matter that the modification to |
You are right. |
I made PR #108 to address this. I'm using the new version and it works, but the change touches a lot of code, so it would be good to look it over. |
Closed by PR #108 |
There seems to be a lot of code in this library that uses global variables that are shared across multiple processes (for instance, the various parameters for tags to ignore, etc.). This is not a good practice and especially causes problems on Windows. It would be better to reorganize the code so that the global state is stored in an object that is passed to each process.
I encountered this in the form of repeated
NameError: global name 'discardElements' is not defined
errors. This appears to be due to the recent PR #102 that moved the definition of this element inside a function, so it's no longer defined globally.The text was updated successfully, but these errors were encountered: