Skip to content

Commit

Permalink
classes/thumbnail: Fix dangling filehandles
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Nov 25, 2021
1 parent 1f058f7 commit 7df87dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/classes/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ def do_GET(self):

# Send message back to client
if os.path.exists(thumb_path):
if not only_path:
self.wfile.write(open(thumb_path, 'rb').read())
else:
if only_path:
self.wfile.write(bytes(thumb_path, "utf-8"))
else:
with open(thumb_path, 'rb') as f:
self.wfile.write(f.read())

# Pause processing of request (since we don't currently use thread pooling, this allows
# the threads to be processed without choking the CPU as much
# TODO: Make HTTPServer work with a limited thread pool and remove this sleep() hack.
time.sleep(0.01)

0 comments on commit 7df87dd

Please sign in to comment.