Improve file handling in serializers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wsgi-oops |
Confirmed
|
Low
|
Ubuntu One Foundations+ team |
Bug Description
As per facundobatista's review on lp:~nataliabidart/wsgi-oops/serializer-thread-safe, we should improve file handling using a manager like this one (untested code):
class FHManager(object):
def __init__(self, instance_fh):
self._fh = None
def __enter__(self, filename):
if self._instance_fh:
return self._instance_fh
if os.path.
fh = open(filepath, "w")
else:
fh = open(filepath, "a")
self._fh = fh
return fh
def __exit__(self, type, value, tb):
if self._fh:
And then, within the file serializer, make a cal like this one:
with self.fh_
...
Changed in wsgi-oops: | |
status: | New → Confirmed |
assignee: | nobody → Naty Bidart (nataliabidart) |
importance: | Undecided → Low |
Changed in wsgi-oops: | |
assignee: | Naty Bidart (nataliabidart) → Ubuntu One Foundations+ team (ubuntuone-foundations+) |