-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Been going through cwrap.py and concore.py and noticed we're opening files without context managers in a bunch of places. Lines like:
apikey=open(concore.inpath+'1/concore.apikey',newline=None).readline().rstrip()and
infile = open(inpath+str(port)+"/"+name);
ins = infile.read()While CPython's GC usually handles this, it's not guaranteed especially if something crashes or throws an exception before we finish reading. Plus in cwrap.py there are open calls happening repeatedly in loops which could leak descriptors if things go wrong.
Would be good to refactor these to use with open(...) as f: statements. Not super urgent since it's working now, but it's the right way to handle resources in Python and prevents potential issues down the line.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels