Repository navigation
Python 3 support - #77
Merged
Merged
Conversation
* Attaching DButils bound methods to the Processqueue table instance meant Processqueue kept a reference to DButils, and DButils had a reference to that instance, thus circular reference and DButils.__del__ was never called, and database session not closed. Only showed as an error in Python 3, but always there. * The Processqueue object was never used outside of DButils, and these methods only work in conjunction with DButils, so making them explicit DButils methods instead of pseudo-methods of Processqueue is reasonable.
* long are change to int; this is probably actually a better match, since the database types were probably not Python longs (which are not the same as C longs) * Several return types are forced to list instead of iterable. These maybe would be managable by making sure the caller accepts an iterable instead of assuming a list, but the API has been using lists pretty consistently, and that also helps with (e.g.) the database query being completed and all data returned.
* Output needs to be a list anyhow. There are other places in the code claiming map is faster but that needs to be evaluated (particularly on Python 3) and it's usually not the case with a lambda.
* Removes all the metaclass programming at the cost of ()
* Not tested on Python 3, just doing a scrub.
* Explicitly close a handler on file change
* Explicitly specify an encoding for the handler; this seems to avoid
issues with logging from DButils.__del_ failing on interpreter exit
* Nested exception handling results in messy traceback in Python 3
* getAllFilenames may have been updated since this script was updated, since it seemed to be expecting something where the filename was the first entry, without the full path, and what it was getting was the full path by itself. So it always tried to delete "/"
* Leaving the dbutils instance to be cleaned up at interpreter exit means the __del__ method can't cleanly close db, so close before that. * Similarly, don't exit() if nothing to reprocess, continue and display "0 files to reprocess".
* Was saying product, but actually done by instrument
* None is no longer comparable
jtniehof
force-pushed
the
py3k
branch
2 times, most recently
from
April 5, 2021 15:59
fd897ce to
3b9db83
Compare
* Also grab latest Python (2 and 3), not specific version
* Remove Inspector.EphemeralCallable reference, as it's gone * Fix format of a note in ProcessqueueRawadd; it was always bad but probably the docstring wasn't being built.
dnadeau-lanl
approved these changes
Apr 5, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR provides Python 3 support and fixes a couple of small issues that were found along the way, mostly with scripts. Python 2 is still supported (same code).
The "port" consisted of:
scriptsdirectory was checked with 2to3 (although the output was not blindly accepted), then run and patched up if the output wasn't the same in 2 and 3. For a lot of these, there were issues where Python 3 shuts down the interpreter in a different order. If aDButilsinstance is still instantiated at shutdown, its__del__method may be called after sqlalchemy is shut down, and so theCloseDBmethod fails. So many scripts were updated to explicitly delete theDButilsinstance if it didn't go out of scope before the end of the script.PR Checklist
Closes #if this PR closes the issue, or some other reference, such asSee #if it is related in some other way)