Skip to content

Commit

Permalink
bug fix: disable streaming for csv upload for now
Browse files Browse the repository at this point in the history
with streaming, if an incomplete csv file was 
sent (for example, 'test/file'), DictReader 
would go into an infinite loop waiting for the 
rest of the file, causing the webstore process 
to hang
  • Loading branch information
John Glover committed Sep 26, 2011
1 parent c1fadc2 commit a89dd17
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions webstore/formats/ft_csv.py
Expand Up @@ -5,12 +5,22 @@
#from ilines import ilines

def csv_request(request):
reader = DictReader(request.stream)
reader = DictReader(StringIO(request.data))
for row in reader:
yield dict([(k, v.decode('utf-8') if v is not None else '') \
for k,v in row.items()])
if request.stream.is_exhausted:
break
yield row

# streaming disabled for now
#
# with streaming, if an incomplete csv file was sent (for example, 'test/file'),
# DictReader would go into an infinite loop waiting for the rest of the file,
# causing the webstore process to hang
#
# reader = DictReader(request.stream)
# for row in reader:
# yield dict([(k, v.decode('utf-8') if v is not None else '') \
# for k,v in row.items()])
# if request.stream.is_exhausted:
# break

def _csv_line(keys, row):
sio = StringIO()
Expand Down

1 comment on commit a89dd17

@rufuspollock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been really nice to have seen a failing test for this (separate from fix) :-)

Please sign in to comment.