-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
I have no idea how to solve this one, but when trying to return strings from a function decorated with an @threads, rather than executing, it simply errors. Code below to reproduce:
def download_nm(delimiter, source, dump):
images = [line.split(delimiter)[10] for line in open(source)][1:] # avoid header row
with open(dump, 'a') as sink:
for i, image in enumerate(images):
results = return_image_json(image) # type(results) == <type 'instance'>
sink.write(results) # Error, expected string or buffer
@threads(16)
def return_image_json(image_link):
response = requests.get(image_link)
encoded = "data:%s;base64,%s" % (response.headers['Content-Type'], base64.b64encode(response.content))
return json.dumps({image_link: encoded}) + '\n'It looks like moving to new-style classes resolves this issue, but since you're relying on some of the syntax-hacks of old-style classes I'm not sure if this is solvable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels